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

# Restore Standalone Host Schemas in the IOP Agent CLI Contract

## For the Implementing Agent

Run every verification command, record actual notes and stdout/stderr in `CODE_REVIEW-*-G??.md`, keep both active files in place, and report ready for review. Finalization is owned by the code-review skill. If blocked, record only the exact blocker, attempted commands/output, and resume condition in implementation-owned evidence fields. Do not ask the user, call user-input tools, create control-plane stop files, classify the next state, archive logs, or write `complete.log`.

## Background

The second review confirmed that shared `agenttask`/`agentguard` ownership is now delegated correctly and that the local-control contract is complete. The same repair over-pruned the standalone boundary, however, removing the contract-first configuration, checkpoint, overlay, change-set, and host presentation schemas assigned to this task by the approved SDD. Restore only those host-owned records without reintroducing shared manager, guardrail, review, admission, or integration-port rules.

## Archive Evidence Snapshot

- Prior task: `agent-task/m-iop-agent-cli-runtime/05_contract_boundary`
- Archived plan: `agent-task/m-iop-agent-cli-runtime/05_contract_boundary/plan_cloud_G07_1.log`
- Archived review: `agent-task/m-iop-agent-cli-runtime/05_contract_boundary/code_review_cloud_G07_1.log`
- Verdict: `FAIL`
- Findings: 1 Required, 0 Suggested, 0 Nit.
- Required fix: restore the contract-first standalone host schemas and their precedence, identity, versioning, persistence, and failure semantics while preserving `iop.agent-runtime` as the sole owner of shared manager/guardrail/review/integration-port behavior.
- Affected files: `agent-contract/index.md`, `agent-contract/inner/iop-agent-cli-runtime.md`.
- Verification evidence: fresh ownership and local-control searches matched the implementation record; fresh `go test -count=1 ./packages/go/agenttask ./packages/go/agentguard` and `git diff --check` passed. A focused reviewer assertion found `RuntimeConfig`, `ProjectRegistration`, `SelectionPolicy`, `PreviewRequest`, `WorkspaceSnapshot`, `OverlayWorkspace`, `ChangeSet`, `IntegrationRecord`, `ProjectLogRecord`, and `IntegrationStatus` absent from the CLI contract.
- Roadmap carryover: the approved SDD is unlocked. This preparatory contract task does not check a Milestone Task on PASS; it provides contract anchors for later S05-S09/S18-S19 implementations and preserves the completed S11/S15 local-control definition.
- Read the two archived files above only if exact prior-loop wording is required; do not scan `agent-task/archive/**`.

## Analysis

### Files Read

- `agent-contract/index.md`
- `agent-contract/inner/iop-agent-cli-runtime.md`
- `agent-contract/inner/agent-runtime.md`
- `agent-roadmap/phase/automation-runtime-bridge/PHASE.md`
- `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md`
- `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md`
- `agent-ops/rules/project/rules.md`
- `agent-ops/rules/project/domain/platform-common/rules.md`
- `agent-ops/rules/project/domain/testing/rules.md`
- `agent-test/local/rules.md`
- `agent-test/local/platform-common-smoke.md`
- `agent-task/m-iop-agent-cli-runtime/05_contract_boundary/plan_cloud_G07_1.log`
- `agent-task/m-iop-agent-cli-runtime/05_contract_boundary/code_review_cloud_G07_1.log`

### SDD Criteria

- SDD: `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md`
- Status: approved; SDD lock: unlocked.
- Targeted scenarios: S05 `config-registry`, S06 `target-policy`, S07 `quota-failure`, S08 `workflow-evidence`, S09 `state-recovery`, S18 `overlay-workspace`, and S19 `change-set-integration`.
- Interface Contract lines 80-105 assign the standalone repo/local configuration, preview, workspace snapshot, overlay, change-set, integration record, log, and integration-status contract to the first contract task.
- The Evidence Map requires later implementations to prove immutable configuration revisions, route history, retained recovery identity, isolated writable layers, and exact immutable change-set integration. The checklist therefore restores the host-owned record definitions and a deterministic anchor assertion while leaving shared execution algorithms delegated.
- S11/S15 are not reimplemented here; their accepted local-control and client-process definitions must remain unchanged.

### Test Environment Rules

- `test_env=local`.
- `agent-test/local/rules.md` was present and read.
- `agent-test/local/platform-common-smoke.md` was present and read. Its proto generation, transport tests, and Edge-Node full-cycle checks do not apply because this task changes no `proto/**`, `packages/go/**`, `configs/**`, or runtime wire behavior.
- The local rule requires a Go environment preflight before the fresh shared-runtime regression command.
- Contract-specific verification uses deterministic `rg --sort path` output and shell assertions. No external, field, Docker, device, or live-provider preflight applies.
- No test-rule maintenance is needed.

### Test Coverage Gaps

- No Go test validates Markdown contract ownership or SDD-to-contract schema completeness.
- Existing `agenttask` and `agentguard` tests are regression evidence only and cannot detect removed contract-first host schemas.
- A deterministic assertion over every required standalone host anchor is required and must remain in final verification.

### Symbol References

No production symbol is renamed or removed. The restored names are contract-first SDD anchors and must not be represented as existing `packages/go/agenttask` or `packages/go/agentguard` implementation types.

### Split Judgment

Keep one plan. The single-source ownership invariant and the host schema definitions must change atomically: restoring schemas without explicit shared-runtime delegation would recreate the original duplicate-owner defect, while delegation without the schemas leaves dependent tasks without a usable standalone contract.

### Scope Rationale

Modify only `agent-contract/index.md` and `agent-contract/inner/iop-agent-cli-runtime.md`. Do not change `iop.agent-runtime`, Go code, proto, YAML, SDD, roadmap, tests, local-control operations, or dependent task artifacts. Restore host record meaning, not shared manager algorithms or speculative implementation paths.

### Final Routing

- `evaluation_mode=isolated-reassessment`
- `finalizer=finalize-task-policy.sh`, `finalizer_mode=pair`
- Build closures: scope/context/verification/evidence/ownership/decision all closed.
- Build grade scores: scope coupling 2, state/concurrency 1, blast/irreversibility 1, evidence/diagnosis 2, verification complexity 1; total `G07`.
- Build base basis: `local-fit`; route basis: `recovery-boundary`; route: `cloud`; filename: `PLAN-cloud-G07.md`.
- Review closures: scope/context/verification/evidence/ownership/decision all closed.
- Review grade scores: 2/1/1/2/1; route basis: `official-review`; route: `cloud`; filename: `CODE_REVIEW-cloud-G07.md`.
- `large_indivisible_context=false`.
- Positive loop risks: `temporal_state`, `concurrent_consistency`, `boundary_contract`, `structured_interpretation`; count 4.
- Recovery signals: `review_rework_count=2`, `evidence_integrity_failure=false`.
- Capability gap: none.

## Implementation Checklist

- [x] Restore the SDD-assigned standalone host configuration, preview, durable isolation/change-set, log, and integration-status schema anchors with explicit ownership, revision, persistence, and typed failure semantics.
- [x] Update the contract index read anchors while preserving `iop.agent-runtime` as the sole shared implementation owner and preserving the existing local-control boundary.
- [x] Run deterministic ownership, host-schema, and local-control assertions, the fresh shared-runtime regression tests, and `git diff --check`, then record exact output.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

### [REVIEW_API-1] Restore the standalone host schema boundary

**Problem:** `agent-contract/inner/iop-agent-cli-runtime.md:41-46` reduces all non-local-control host responsibilities to four general rules. This removes the contract-first schemas assigned by `agent-roadmap/sdd/automation-runtime-bridge/iop-agent-cli-runtime/SDD.md:80-105` and contradicts the prior plan's requirement to keep repo/local configuration, concrete isolation-backend and change-set persistence, and versioned host failure records.

**Solution:** Add a concise standalone host schema section that defines:

- `RuntimeConfig`, `ProjectRegistration`, `SelectionPolicy`, and `PreviewRequest` as host configuration/control inputs with repo-global read-only precedence, user-local ownership, immutable revisions, ordered-array replacement, and no-side-effect preview behavior.
- `WorkspaceSnapshot`, `OverlayWorkspace`, `ChangeSet`, and `IntegrationRecord` as versioned host backend/persistence records that preserve immutable shared-runtime identities, exact base/change-set revisions, retention, rollback/blocker, and recovery state.
- `ProjectLogRecord` and `IntegrationStatus` as host-owned presentation/recovery projections without taking ownership of shared execution or integration decisions.
- Typed corrupt/mismatched/unsupported-version handling with no silent reset or rebinding.
- An index reading-condition anchor for every restored name, while keeping implementation source status contract-first and keeping `iop.agent-runtime` authoritative for shared ports and algorithms.

Before (`agent-contract/inner/iop-agent-cli-runtime.md:41`):

```markdown
## Host configuration and ownership rules

- Repo-global configuration is a read-only, versioned input.
- Host-local records must version their schema.
- Host isolation and change-set implementations are extension points.
```

After:

```markdown
## Standalone host schemas and durable records

| Schema | Host-owned contract |
|---|---|
| `RuntimeConfig` | Repo-global/user-local revisions, precedence, replacement arrays, and local roots. |
| `WorkspaceSnapshot` | Exact immutable base fingerprint and referenced revisions. |
| `IntegrationRecord` | Exact change-set/integration attempt, outcome, blocker, rollback, and retention identity. |
```

Keep the table concise but define every listed schema and the cross-cutting version/failure rules needed by S05-S09/S18-S19. Do not copy `agenttask.Manager` state transitions, `agentguard` admission, review, or integration-port algorithms from `iop.agent-runtime`.

**Modified Files and Checklist:**

- [x] `agent-contract/inner/iop-agent-cli-runtime.md`: restore all ten host schema anchors and their standalone ownership/version/failure semantics; retain current shared-runtime delegation and local-control sections.
- [x] `agent-contract/index.md`: add all ten schema names to the `iop.agent-cli-runtime` reading condition and keep the source column free of `packages/go/agenttask/**` or `packages/go/agentguard/**` claims.

**Test Strategy:** Do not add Go tests because this changes only Markdown contract definitions. Add no repository test script; use the final deterministic shell assertions as direct contract verification, and rerun the existing shared-runtime packages with `-count=1` as a regression guard.

**Verification:** Every required standalone schema appears in both the contract and index row, shared runtime package paths remain absent from the CLI row, local-control anchors remain present, fresh shared package tests pass, and the diff has no whitespace errors.

## Modified Files Summary

| File | Item |
|---|---|
| `agent-contract/inner/iop-agent-cli-runtime.md` | REVIEW_API-1 |
| `agent-contract/index.md` | REVIEW_API-1 |

## Final Verification

```bash
command -v go && readlink -f "$(command -v go)" && go version && go env GOROOT
```

```bash
cli_row="$(rg '^\| `iop\.agent-cli-runtime`' agent-contract/index.md)"
printf '%s\n' "$cli_row"
! printf '%s\n' "$cli_row" | rg -q 'packages/go/agent(task|guard)'
rg --sort path -n 'iop\.agent-runtime|shared contract dependency|implementation source status' agent-contract/index.md agent-contract/inner/iop-agent-cli-runtime.md agent-contract/inner/agent-runtime.md
```

```bash
cli_row="$(rg '^\| `iop\.agent-cli-runtime`' agent-contract/index.md)"
symbols=(RuntimeConfig ProjectRegistration SelectionPolicy PreviewRequest WorkspaceSnapshot OverlayWorkspace ChangeSet IntegrationRecord ProjectLogRecord IntegrationStatus)
for symbol in "${symbols[@]}"; do
  rg -q "\b${symbol}\b" agent-contract/inner/iop-agent-cli-runtime.md
  printf '%s\n' "$cli_row" | rg -q "\b${symbol}\b"
done
rg --sort path -n 'RuntimeConfig|ProjectRegistration|SelectionPolicy|PreviewRequest|WorkspaceSnapshot|OverlayWorkspace|ChangeSet|IntegrationRecord|ProjectLogRecord|IntegrationStatus' agent-contract/index.md agent-contract/inner/iop-agent-cli-runtime.md
```

```bash
rg --sort path -n 'LocalControl(Envelope|Request|Response|Event|Error)|command_id|peer credential|same OS user|replay|S11|S15' agent-contract/index.md agent-contract/inner/iop-agent-cli-runtime.md
```

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

```bash
git diff --check
```

Expected: the Go environment is consistent; the CLI row delegates shared ownership; all ten standalone host schema anchors and all local-control anchors are present; fresh shared package tests pass; and the diff has no whitespace errors.

After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.
