<!-- task=m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure plan=2 tag=REVIEW_REVIEW_TEST -->

# Code Review Reference - REVIEW_REVIEW_TEST

> **[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-07-30
task=m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure, plan=2, tag=REVIEW_REVIEW_TEST

## Roadmap Targets

- Milestone: `agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md`
- Milestone link: [Milestone document](agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-cli-runtime.md)
- Task ids:
  - `logged-smoke`: authenticated macOS discovery-through-completion multi-project field validation
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- Prior task: `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure`
- Prior plan: `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/plan_cloud_G10_1.log`
- Prior review: `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/code_review_cloud_G10_1.log`
- Verdict: FAIL
- Findings: five Required, zero Suggested, zero Nit. Canonical verdict parsing and official-review confinement are incorrect; shared selection, Pi same-context repair, and post-apply validation are not composed; the S14 harness can fabricate lifecycle success; and the real macOS manifest is absent.
- Affected files: standalone taskloop provider/evidence/review/integration/module adapters, CLI and daemon composition, S14 harness/schema/Make targets, standalone contract, and field evidence.
- Verification evidence: fresh focused tests, race tests, vet, builds, Darwin cross-build, shell syntax, smoke preflight, and `git diff --check` passed on Linux arm64. A fresh `go test -count=1 ./...` observed one unrelated `apps/edge/internal/controlplane` failure; ten isolated reruns of that test passed. The field harness stopped at the non-Darwin gate with exit 69 and produced no real manifest.
- Routing signals: `review_rework_count=2`, `evidence_integrity_failure=true`.
- Roadmap carryover: this task remains the sole completion owner for `logged-smoke`; task 26 remains dependency-waiting.

## 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-G10.md` → `code_review_cloud_G10_2.log` and `PLAN-cloud-G10.md` → `plan_cloud_G10_2.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS and task group is `m-iop-agent-cli-runtime`, report completion event metadata. Roadmap state check and `update-roadmap` calls are runtime responsibilities.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_REVIEW_TEST-1 Confine review and restore same-context evidence | [ ] |
| REVIEW_REVIEW_TEST-2 Compose shared policy and real validation | [ ] |
| REVIEW_REVIEW_TEST-3 Bind S14 claims to runtime evidence | [ ] |
| REVIEW_REVIEW_TEST-4 Produce exact-revision field evidence | [ ] |

## Implementation Checklist

- [ ] Correct canonical official-review parsing, exact retained confinement, and Pi same-native-context repair with deterministic zero-real-provider regressions.
- [ ] Compose common ordered selection/continuation semantics and a mandatory post-apply validator into both CLI and daemon, with end-to-end persisted lifecycle/rollback tests.
- [ ] Harden the S14 harness, manifest schema, and Make preflight so every lifecycle claim is derived from bounded runtime evidence and fabricated success is rejected.
- [ ] Run fresh local verification, then exact-revision dev macOS preflight and field execution; attach the validated redacted manifest and update the standalone contract with only verified evidence.
- [ ] 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_G10_2.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G10_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`.
- [ ] 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-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/` to `agent-task/archive/YYYY/MM/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-iop-agent-cli-runtime`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-agent-cli-runtime/` 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

_Record any deviations from the plan and the rationale here._

## Key Design Decisions

_Record key design decisions here._

## Reviewer Checkpoints

- Canonical Agent-Ops `Overall Verdict:` artifacts parse without accepting ambiguous fields or multiple conflicting verdicts.
- Worker, official-review, and Pi repair processes use the exact retained executable confinement; every identity mismatch launches zero provider processes.
- Pi repair resumes the persisted native session and still requires a fresh exact evidence match before official review.
- `taskloop.Runtime` delegates ordered selection and continuation to common policy and never treats a missing post-apply validator as success.
- CLI and daemon tests drive one persisted manager through provider submission, canonical review, validation failure/rollback, sibling continuation, restart, project logs, and terminal evidence without a real provider CLI.
- S14 self-test rejects fabricated lifecycle claims and missing discovery/quota/session/log/archive evidence.
- The final manifest comes from the exact reviewed source on an authenticated Darwin runner, validates against the schema, contains no secret or raw home path, and binds every claim to bounded evidence.

## Verification Results

### Official Review, Evidence Repair, and Provider Confinement

```bash
go test -count=1 ./apps/agent/internal/taskloop -run 'Test(ReadReviewVerdict|CatalogReviewExecutor|PiEvidenceRepair|Provider)'
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr._
```

### Runtime Composition and Persisted Lifecycle

```bash
go test -count=1 ./apps/agent/internal/taskloop ./apps/agent/cmd/agent ./apps/agent/internal/bootstrap
go test -count=1 -race ./apps/agent/internal/taskloop ./apps/agent/cmd/agent ./apps/agent/internal/bootstrap ./packages/go/agenttask ./packages/go/agentstate
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr._
```

### S14 Harness Self-Test

```bash
bash -n scripts/e2e-iop-agent-logged-smoke.sh
make test-iop-agent-logged-smoke-preflight
make -n test-iop-agent-logged-smoke
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr._
```

### External macOS Preflight

```bash
ssh toki@toki-labs.com '
  set -eu
  cd /Users/toki/agent-work/iop-dev
  uname -srm
  git branch --show-current
  git rev-parse HEAD
  git status --short
  command -v go
  command -v jq
  command -v codex
  command -v claude
  go version
'
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr or the exact blocker and resume condition._
```

### Exact-Revision Logged-in macOS Field Run

```bash
make test-iop-agent-logged-smoke \
  IOP_AGENT_SMOKE_LOCAL_CONFIG="$IOP_AGENT_SMOKE_LOCAL_CONFIG" \
  IOP_AGENT_SMOKE_PROJECT_A="$IOP_AGENT_SMOKE_PROJECT_A" \
  IOP_AGENT_SMOKE_PROJECT_B="$IOP_AGENT_SMOKE_PROJECT_B" \
  IOP_AGENT_SMOKE_OUTPUT="$IOP_AGENT_SMOKE_OUTPUT"
scripts/e2e-iop-agent-logged-smoke.sh \
  --validate-manifest "$IOP_AGENT_SMOKE_OUTPUT/manifest.json"
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr or the exact blocker and resume condition._
```

### Field Manifest Validation and Redaction

```bash
jq -e . agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/logged-smoke-manifest.json >/dev/null
scripts/e2e-iop-agent-logged-smoke.sh \
  --validate-manifest agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/logged-smoke-manifest.json
if rg -n -i 'authorization|bearer|api[_-]?key|token|/Users/|/home/' \
  agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/logged-smoke-manifest.json; then
  exit 1
fi
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr._
```

### Final Local Verification

```bash
gofmt -w \
  apps/agent/internal/taskloop/provider.go \
  apps/agent/internal/taskloop/provider_test.go \
  apps/agent/internal/taskloop/evidence.go \
  apps/agent/internal/taskloop/evidence_test.go \
  apps/agent/internal/taskloop/review.go \
  apps/agent/internal/taskloop/review_test.go \
  apps/agent/internal/taskloop/integration.go \
  apps/agent/internal/taskloop/integration_test.go \
  apps/agent/internal/taskloop/module.go \
  apps/agent/internal/taskloop/module_test.go \
  apps/agent/cmd/agent/main.go \
  apps/agent/cmd/agent/main_test.go \
  apps/agent/internal/bootstrap/module.go \
  apps/agent/internal/bootstrap/module_test.go
go test -count=1 ./apps/agent/internal/taskloop ./apps/agent/cmd/agent ./apps/agent/internal/bootstrap ./apps/agent/internal/command
go test -count=1 -race ./apps/agent/internal/taskloop ./apps/agent/cmd/agent ./apps/agent/internal/bootstrap ./packages/go/agenttask ./packages/go/agentstate
go vet ./apps/agent/internal/taskloop ./apps/agent/cmd/agent ./apps/agent/internal/bootstrap ./packages/go/...
bash -n scripts/e2e-iop-agent-logged-smoke.sh
make build-agent
GOOS=darwin GOARCH=arm64 go build -trimpath -o /tmp/iop-agent-review-darwin-arm64 ./apps/agent/cmd/agent
make test-iop-agent-logged-smoke-preflight
go test -count=1 ./...
git diff --check
```

Actual stdout/stderr:

```text
_Paste actual stdout/stderr. If output is saved because it is long, record the exact output path and command._
```

---

> **[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) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| 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 |
|-----------|------------|
| Correctness | Fail |
| Completeness | Fail |
| Test Coverage | Fail |
| API Contract | Fail |
| Code Quality | Fail |
| Implementation Deviation | Fail |
| Verification Trust | Fail |
| Spec Conformance | Fail |

### Findings

- Required — `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/CODE_REVIEW-cloud-G10.md:37` leaves every implementation item and checklist entry unchecked, and every verification section still contains `_Paste actual stdout/stderr._`. No current-loop implementation or verification evidence exists, so the planned work is not reviewable. Implement the active plan and replace every implementation-owned placeholder with exact command output or an exact blocker and resume condition.
- Required — `apps/agent/internal/taskloop/review.go:224` still parses the noncanonical `Verdict:` spelling, while `apps/agent/internal/taskloop/review.go:270-294` still executes official review through a raw catalog provider outside the retained executable confinement. `apps/agent/internal/taskloop/evidence.go:94-111` also still has no production same-native-context Pi repair path. Implement the canonical single-verdict parser, exact retained-confinement review launch, and exact persisted-session Pi repair/rematch matrix with zero-launch mismatch assertions.
- Required — `apps/agent/internal/taskloop/module.go:505-531` still selects the static registration default instead of delegating to the shared ordered policy and continuation semantics; `apps/agent/internal/taskloop/module.go:214` supplies no Pi repairer; and `apps/agent/internal/taskloop/integration.go:25-29` still converts a missing validator into success for a live context. The CLI and daemon constructors continue to omit these dependencies. Compose the common policy, repair, and mandatory post-apply validator through both application entry points, then add persisted lifecycle tests for review, validation failure, rollback, sibling continuation, and restart.
- Required — `scripts/e2e-iop-agent-logged-smoke.sh:285-287` still accepts `completed` while waiting for `running`; `scripts/e2e-iop-agent-logged-smoke.sh:494-495` hashes status projections as terminal evidence; and `scripts/e2e-iop-agent-logged-smoke.sh:536-544` still emits hard-coded lifecycle success. The schema likewise requires booleans without bounded discovery, quota, invocation/session, project-log, cancellation, restart, or archive locators. Derive each claim from bounded runtime evidence and extend self-test coverage so every fabricated or missing evidence variant is rejected.
- Required — `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/logged-smoke-manifest.json` is absent. SDD S14 and the `logged-smoke` Evidence Map require a schema-valid redacted manifest from the exact reviewed revision on an authenticated macOS two-project runner. After the repository-fixable defects pass fresh local verification, run the declared dev preflight and field target, validate/redact the manifest, and record the exact evidence in the review artifact and standalone contract.

### Routing Signals

- review_rework_count=3
- evidence_integrity_failure=true

### Next Step

- Prepare and materialize a freshly routed follow-up PLAN/CODE_REVIEW pair for the same task path; do not write `complete.log` or update the roadmap.
