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

# Code Review Reference - 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.

## Overview

date=2026-07-30
task=m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure, plan=1, tag=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_G09_0.log`
- Prior review: `agent-task/m-iop-agent-cli-runtime/25+19,21,22,23,24_logged_smoke_closure/code_review_cloud_G09_0.log`
- Verdict: FAIL
- Required findings: the harness/schema and Make targets were absent; implementation evidence was placeholder-only; `apps/agent/cmd/agent/main.go` and `apps/agent/internal/bootstrap/module.go` still failed closed because no authoritative task runtime was composed; the original `25 -> 26` split therefore formed a verification dependency cycle.
- Verification evidence: Linux arm64 returned `missing` for both planned smoke files, both Make probes exited 2, and `TestRunLifecycleFailsClosed` passed, confirming the unavailable production boundary.
- Roadmap carryover: this packet remains the sole completion owner for `logged-smoke`; `parity-cutover` remains owned by task 26.

## For the Review Agent

> **[REVIEW AGENT ONLY]** Implementing agents must not execute finalization.

Compare implementation of each item against source files and verify that output in `Verification Results` matches code. Require a schema-valid redacted macOS manifest for PASS.

1. Append verdict and `review_rework_count` / `evidence_integrity_failure` routing signals.
2. Archive `CODE_REVIEW-cloud-G10.md` to `code_review_cloud_G10_1.log` and `PLAN-cloud-G10.md` to `plan_cloud_G10_1.log`.
3. If PASS, write `complete.log`, move the task directory to the dated archive, and report `logged-smoke` completion metadata without editing the roadmap. If WARN/FAIL, write the exact next state.
4. Complete the review-only checklist at the final log path.

## Implementation Item Completion

| Item | Status |
|------|--------|
| REVIEW_TEST-1 Standalone adapters | [ ] |
| REVIEW_TEST-2 CLI/daemon composition | [ ] |
| REVIEW_TEST-3 S14 harness/schema | [ ] |
| REVIEW_TEST-4 Make/local verification | [x] |
| REVIEW_TEST-5 macOS field closure | [ ] |

## Implementation Checklist

- [ ] Implement and test standalone project workflow, provider, recovery, evidence, review, integration, and event adapters over the existing shared runtime contracts.
- [ ] Compose one authoritative task runtime into the CLI and daemon so selection, preview, start/stop/resume, status, local control, restart recovery, and project logs use persisted manager state.
- [ ] Add a fail-fast, cleanup-safe macOS S14 harness and bounded manifest schema covering the complete two-project lifecycle and redaction contract.
- [x] Add stable Make targets and run fresh local syntax, package, race, build, cross-build, preflight, manifest rejection/redaction, cleanup, and diff verification.
- [ ] Run the exact harness on an actual logged-in macOS runner, attach the schema-valid redacted manifest, and update the standalone contract with the implemented S10/S14 sources and evidence.
- [x] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** Implementing agents must not modify this checklist.

- [x] Append one verdict and verified routing signals.
- [x] Verify dimensions, field evidence, and finding classifications.
- [x] Archive `CODE_REVIEW-cloud-G10.md` as `code_review_cloud_G10_1.log`.
- [x] Archive `PLAN-cloud-G10.md` as `plan_cloud_G10_1.log`.
- [x] Verify the Agent-Ops managed `.gitignore` block.
- [ ] If PASS, write canonical `complete.log` and leave no active Markdown files.
- [ ] If PASS, move this task directory to the dated archive and update this checklist there.
- [ ] If PASS, report `logged-smoke` completion metadata without editing the roadmap.
- [ ] If PASS, keep the split parent only because task 26 or group logs remain.
- [x] If WARN/FAIL, materialize the exact next state without `complete.log`.

## Deviations from Plan

- REVIEW_TEST-5 was not executed because the available host is `Linux 6.10.14-linuxkit aarch64`, not Darwin, and no authenticated macOS runner or two exact-revision clean field clones are available in this environment. The harness correctly stops at its pre-login Darwin gate with exit 69.
- `apps/agent/internal/command/root.go`, `apps/agent/internal/command/root_test.go`, `apps/agent/internal/command/service.go`, and `configs/iop-agent.providers.yaml` were also updated. The command files propagate the provider catalog to lifecycle mutation requests, while the catalog declares the executable writable-root confinement capability already required by `agentguard`.

## Key Design Decisions

- `agenttask.Manager` remains the sole lifecycle and scheduling owner. `taskloop.Runtime` supplies only registered-project workflow parsing and the required provider, recovery, evidence, review, integration, and event ports.
- CLI reads open a side-effect-free projection over the checksum-protected state. CLI mutations reconstruct bounded manager ownership without reconciliation; only the sustained daemon component runs reconciliation.
- The daemon composes the task runtime, project-log sink, client manager, and local-control bridge over one `agentstate.Store`. A provider catalog is mandatory; no synthetic production fallback is accepted.
- Provider execution consumes only the exact `StartedConfinement` returned by the workspace proof. Tests use a deterministic shell fixture and never execute a real provider CLI.
- Evidence, recovery, and official review resolve the retained isolated task view. They never read provider output from or fall back to the canonical registered workspace.
- The logged-smoke harness validates source, binary, configuration, authentication, clone, socket, and process identities before lifecycle mutation; its cleanup is fenced by the exact daemon PID/start identity.
- The manifest contains only fixed allow-listed hashes, enums, booleans, and the relative `manifest.json` locator. Validation rejects extra fields, credentials, raw user paths, unbounded size, and invalid lifecycle states.

## Reviewer Checkpoints

- Shared `agenttask.Manager` remains the only lifecycle owner; application adapters translate and compose only.
- Registered-project CLI and local-control operations use one persisted authoritative runtime and preserve unknown/unselected fail-closed behavior.
- Tests launch no real provider process; confinement and provider calls use deterministic fakes.
- Harness preflight validates exact source, binary, config, login, workspace, socket, and process identities before mutation.
- Cancellation or failure of one project does not stop the sibling; restart and terminal archives preserve exact identities.
- Manifest validation rejects credentials, raw home paths, unbounded output, and unexpected fields.

## Verification Results

### Focused and race

```bash
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/...
```

Actual output:

```text
ok  	iop/apps/agent/internal/taskloop	1.792s
ok  	iop/apps/agent/cmd/agent	2.187s
ok  	iop/apps/agent/internal/bootstrap	0.172s
ok  	iop/apps/agent/internal/command	0.013s

ok  	iop/apps/agent/internal/taskloop	5.844s
ok  	iop/apps/agent/cmd/agent	4.785s
ok  	iop/apps/agent/internal/bootstrap	1.379s
ok  	iop/packages/go/agenttask	3.061s
ok  	iop/packages/go/agentstate	1.186s

go vet: exit 0, no stdout/stderr
```

### Build and local smoke preflight

```bash
bash -n scripts/e2e-iop-agent-logged-smoke.sh
make build-agent
GOOS=darwin GOARCH=arm64 go build -trimpath -o /tmp/iop-agent-darwin-arm64 ./apps/agent/cmd/agent
make test-iop-agent-logged-smoke-preflight
```

Actual output:

```text
bash -n: exit 0, no stdout/stderr
mkdir -p build/bin
go build -trimpath -o build/bin/iop-agent ./apps/agent/cmd/agent
darwin arm64 cross-build: PASS
bash -n scripts/e2e-iop-agent-logged-smoke.sh
./scripts/e2e-iop-agent-logged-smoke.sh --help >/dev/null
./scripts/e2e-iop-agent-logged-smoke.sh --self-test
logged-smoke: self-test passed (manifest rejection and exact-PID cleanup)
logged-smoke: non-Darwin host gate passed
```

Both Make dry-run targets resolved successfully, and `build/bin/iop-agent --help` exited 0.

### Logged-in macOS field run

```bash
scripts/e2e-iop-agent-logged-smoke.sh \
  --binary "$PWD/build/bin/iop-agent" \
  --repo-config "$PWD/configs/iop-agent.runtime.yaml" \
  --local-config "$IOP_AGENT_SMOKE_LOCAL_CONFIG" \
  --provider-catalog "$PWD/configs/iop-agent.providers.yaml" \
  --project-a "$IOP_AGENT_SMOKE_PROJECT_A" \
  --project-b "$IOP_AGENT_SMOKE_PROJECT_B" \
  --expected-head "$(git rev-parse HEAD)" \
  --output "$IOP_AGENT_SMOKE_OUTPUT"
```

Exact external blocker:

```text
$ uname -srm
Linux 6.10.14-linuxkit aarch64
$ scripts/e2e-iop-agent-logged-smoke.sh --preflight-only
logged-smoke: Darwin host required; observed Linux before provider login or process launch
exit status: 69
```

No provider discovery/login command or provider/daemon process was started by this attempt.

Resume condition: use a Darwin arm64 or amd64 runner with the final reviewed implementation committed at one exact clean HEAD; build the binary from that HEAD; provide the repo runtime config, an owned `0700` state root through the user-local config, the provider catalog, two distinct clean clones at the same HEAD with registered selected tasks, authenticated catalog provider CLIs, no existing daemon process/socket, and a new absolute output directory. Run the exact command above, then validate and attach only its schema-valid redacted `manifest.json`.

### Manifest, regression, and diff

```bash
scripts/e2e-iop-agent-logged-smoke.sh --validate-manifest "$IOP_AGENT_SMOKE_OUTPUT/manifest.json"
rg -n -i 'authorization|bearer|api[_-]?key|token|/Users/|/home/' "$IOP_AGENT_SMOKE_OUTPUT/manifest.json" && exit 1 || true
rg -n --sort path 'standalone runtime lifecycle is not wired|task runtime is unavailable' apps/agent && exit 1 || true
go test -count=1 ./...
git diff --check
```

Local regression output:

```text
$ scripts/e2e-iop-agent-logged-smoke.sh --self-test
logged-smoke: self-test passed (manifest rejection and exact-PID cleanup)

$ rg -n --sort path 'standalone runtime lifecycle is not wired|task runtime is unavailable' apps/agent
exit status: 1 (no matches)

$ go test -count=1 ./...
ok  	iop/apps/agent/cmd/agent
ok  	iop/apps/agent/internal/bootstrap
ok  	iop/apps/agent/internal/clientprocess
ok  	iop/apps/agent/internal/command
ok  	iop/apps/agent/internal/host
ok  	iop/apps/agent/internal/localcontrol
ok  	iop/apps/agent/internal/projectlog
ok  	iop/apps/agent/internal/taskloop
ok  	iop/apps/control-plane/cmd/control-plane
ok  	iop/apps/control-plane/internal/wire
ok  	iop/apps/edge/...
ok  	iop/apps/node/...
ok  	iop/packages/go/...
ok  	iop/scripts/inventory-query
exit status: 0

$ git diff --check
exit status: 0, no stdout/stderr
```

A field manifest is intentionally absent: producing it requires the blocked logged-in macOS execution above. The local self-test created and accepted one safe synthetic manifest, rejected an extra `token` field, and proved exact-PID cleanup without terminating an unrelated fixture process.

---

> **[IMPLEMENTING AGENT — BEFORE SAVING]** Fill every implementation-owned section and leave review-only content unchanged.

## Section Ownership

| Section | Owner | Note |
|---------|-------|------|
| Header, Overview, Roadmap Targets, Archive Snapshot, Review Instructions | Fixed | Implementer must not modify |
| Implementation Item Completion, Implementation Checklist | Implementing agent | Check status only |
| Review-Only Checklist | Review agent | Implementer must not modify |
| Deviations, Decisions, Verification Results | Implementing agent | Record actual implementation and evidence |
| Reviewer Checkpoints | Fixed | Reviewer verifies |
| Code Review Result and finalization | Review agent | Append/execute only after review |

## 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 — `apps/agent/internal/taskloop/review.go:224` parses only `Verdict:` even though the canonical review workflow writes `Overall Verdict:`. The current regression at `apps/agent/internal/taskloop/review_test.go:68` uses the noncanonical spelling and therefore cannot prove compatibility with an actual Agent-Ops review artifact. Parse the canonical field exactly, define any intentional legacy alias explicitly, and add a regression that reads the canonical `## Code Review Result` form.
- Required — `apps/agent/internal/taskloop/review.go:270` constructs a raw catalog profile provider and `apps/agent/internal/taskloop/review.go:285` executes it directly in the retained task workspace. This bypasses the executable workspace-confinement proof used by normal unattended provider execution, so official review is an unconfined production provider path. Route official review through the same validated confinement boundary and add a test that rejects missing, stale, or mismatched confinement before any provider process is launched.
- Required — the production composition does not preserve shared runtime semantics: `apps/agent/internal/taskloop/module.go:505` selects only a static default instead of the common ordered policy/quota/failover evaluator; `apps/agent/internal/taskloop/module.go:214` installs no Pi evidence repair executor; and `apps/agent/internal/taskloop/integration.go:25` converts a missing validator into a successful no-op for a live context. Both production callers at `apps/agent/cmd/agent/main.go:430` and `apps/agent/internal/bootstrap/module.go:193` omit these dependencies. Compose the existing common selector and an executable native-context repair path, require a real post-apply validator or fail construction, and add CLI/daemon lifecycle tests that exercise selection, repair, review, validation failure, rollback, and persisted manager state.
- Required — `scripts/e2e-iop-agent-logged-smoke.sh:427` treats a static catalog listing plus ad hoc login probes as runtime discovery, performs no quota/status assertion, and records no bounded stream/session, project-log, terminal archive, or duplicate-invocation evidence. `wait_for_state` also accepts `completed` while waiting for `running` at line 285, terminal evidence hashes status projections at lines 494-495, and lifecycle booleans are hard-coded at lines 536-544. Replace these assertions with observations from the authoritative runtime, require an actually running state before cancellation, bind each manifest claim to bounded evidence and exact retained locators, and extend self-tests to reject fabricated lifecycle success.
- Required — the schema-valid redacted manifest from an actual authenticated macOS two-project run is absent, as recorded at `CODE_REVIEW-cloud-G10.md:225`. SDD S14 and the active plan make that field run mandatory for PASS. After the implementation and harness defects above are corrected and local checks pass, run the exact reviewed revision on a logged-in macOS runner and attach only the validated redacted manifest and its bounded evidence locators.

### Routing Signals

- review_rework_count=2
- evidence_integrity_failure=true

### Next Step

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