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

# Complete Daemon Wiring

## For the Implementing Agent

Fill implementation-owned sections in `CODE_REVIEW-cloud-G08.md` with actual outputs. Keep the active pair in place and report ready for review. Finalization belongs only to the code-review skill. If blocked, record exact blocker evidence and resume conditions without asking the user, creating stop files, archiving, or writing `complete.log`.

## Background

The completed host, CLI, project-log, local-control, and client-process packets still need one production composition. This packet wires those adapters into one daemon lifecycle and proves atomic startup, cancellation, cleanup, and client-exit isolation without performing authenticated field work.

## Analysis

### Files Read

- `agent-task/m-iop-agent-cli-runtime/24+19,21,22,23_daemon_wiring/plan_cloud_G07_0.log`
- `agent-task/m-iop-agent-cli-runtime/24+19,21,22,23_daemon_wiring/code_review_cloud_G07_0.log`
- Existing predecessor PLAN/review pairs under indices 19, 21, 22, and 23

### SDD Criteria

S14 requires one production binary to exercise the integrated lifecycle. This child supplies the production composition and deterministic local lifecycle evidence but does not claim `logged-smoke` completion.

### Verification Context

Use fresh bootstrap/command tests, race, vet, formatting, build, and diff checks from the original packet. No live provider, login, or macOS runner is required.

### Test Coverage Gaps

- No production bootstrap composes all completed adapters.
- No test proves startup rollback, serve cancellation, component cleanup, or host survival after a client exits.

### Symbol References

None. Composition consumes predecessor APIs without renaming them.

### Split Judgment

Production wiring has a stable local PASS contract. It depends on completed CLI, project-log, local-control, and client-process packets. Authenticated harness and field evidence remain in closure child 25.

### Scope Rationale

Do not add field scripts, manifest schema, provider authentication, Makefile smoke targets, or tracked field evidence.

### Final Routing

- evaluation_mode: `isolated-reassessment`
- finalizer: `finalize-task-policy.sh pair`
- build closures: all `true`; grade scores `2/2/1/1/2`; route `local-fit`, `local-G08`, filename `PLAN-local-G08.md`
- review closures: all `true`; grade scores `2/2/1/1/2`; route `official-review`, `cloud-G08`, filename `CODE_REVIEW-cloud-G08.md`
- large_indivisible_context: `false`
- positive loop risks: `temporal_state`, `concurrent_consistency`, `boundary_contract` (count `3`)
- recovery signals: rework `0`, evidence-integrity failure `false`
- capability-gap evidence: none

## Implementation Checklist

- [ ] Wire the completed host, project-log, local-control, and client-process components into one daemon lifecycle without adding fallback implementations.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

### [TEST-1] Wire the Complete Daemon

#### Problem

The S14 lifecycle requires one production binary, while predecessor packets expose components independently.

#### Solution

Update bootstrap composition and the CLI entry point to construct project logs, local control, and client processes from the same immutable runtime snapshot/state store, then start and stop them through the host. Fail startup atomically and keep provider/runtime ownership alive when a client exits.

#### Modified Files and Checklist

- [ ] `apps/agent/internal/bootstrap/module.go` — compose all completed adapters.
- [ ] `apps/agent/internal/bootstrap/module_test.go` — test wiring, order, and rollback.
- [ ] `apps/agent/cmd/agent/main.go` — use production composition.
- [ ] `apps/agent/cmd/agent/main_test.go` — test serve cancellation and component cleanup.

#### Test Strategy

Add production-composition tests with temp roots and fake provider ports. Do not use live logins.

#### Verification

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

Expected: lifecycle order and cleanup pass without races.

## Dependencies and Execution Order

Predecessors `19+14,16,18_cli_binary_contract`, `21+13,17,20_project_log_sink`, `22+16_local_control`, and `23+14,16,22_client_process_manager` must each produce a same-group active or archived `complete.log`.

## Modified Files Summary

| File | Item |
|------|------|
| `apps/agent/internal/bootstrap/module.go` | TEST-1 |
| `apps/agent/internal/bootstrap/module_test.go` | TEST-1 |
| `apps/agent/cmd/agent/main.go` | TEST-1 |
| `apps/agent/cmd/agent/main_test.go` | TEST-1 |

## Final Verification

```bash
gofmt -w apps/agent/internal/bootstrap/module.go apps/agent/internal/bootstrap/module_test.go apps/agent/cmd/agent/main.go apps/agent/cmd/agent/main_test.go
go test -count=1 -race ./apps/agent/internal/bootstrap ./apps/agent/cmd/agent
go vet ./apps/agent/internal/bootstrap ./apps/agent/cmd/agent
make build-agent
git diff --check
```

Expected: production wiring, race, vet, build, formatting, and diff checks pass. After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.
