<!-- task=m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness plan=2 tag=REVIEW_TEST milestone-task=claude-smoke -->

# 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.
> Execute the plan's selected root cause, scope, files, and dependency decisions as written. Do not choose another owner, narrow/expand the write boundary, or replace a fix with another verification attempt.
> 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-08-07
task=m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness, plan=2, tag=REVIEW_TEST

## Archive Evidence Snapshot

- Reviewed plan: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/plan_cloud_G07_1.log`; reviewed implementation/review: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/code_review_cloud_G07_1.log`; prior pristine pair: `plan_cloud_G07_0.log` and `code_review_cloud_G07_0.log` in the same task directory.
- Verdict: FAIL. Required R1 found that the requested model was not passed through Claude's actual model input and the manifest copied engine facts from constants instead of the validated runtime binding. Required R2 found incomplete fail-before-invocation preflight. Required R3 found a hard-coded verification success for any pre-existing result file. Required R4 found raw temporary capture leaks and non-guaranteed atomic publication.
- Fresh review verification passed the dependency check, shell syntax, current self-test, Make self-test target, target inventory, aggregate isolation, and `git diff --check`. The reviewer also observed multiple fresh `/tmp/tmp.*/out`, `err`, `fresh`, and `manifest` files left by failure-path self-tests.
- Roadmap carryover: `milestone-task=claude-smoke` maps to SDD S12. This packet repairs only the credential-free harness contract; it must not claim the actual Claude/Mac qualification.

## 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-owned-single-request-agent-execution/24+22_claude_smoke_harness/`. If WARN/FAIL, fully write the next filesystem state required by the code-review skill.
4. If PASS, preserve the first-line `milestone-task=claude-smoke` metadata in `complete.log` and report it for runtime aggregation. Roadmap state evaluation belongs to `sync-milestone-workstate`.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| TEST-1 Bind the actual Claude model and immutable stage evidence | [x] |
| TEST-2 Close the fail-before-invocation preflight | [x] |
| TEST-3 Derive the workspace verification result | [x] |
| TEST-4 Clean raw captures and publish atomically | [x] |

## Implementation Checklist

- [x] Bind the requested Claude public model, base URL digest, checked Edge config, closed stage-engine facts, and manifest stage records to one validated immutable runtime evidence snapshot.
- [x] Complete fail-before-invocation preflight for runner/workspace identity, executables/help/version, Edge config, listeners, observation log, metrics, source, secret-name, and output safety, with zero-child negative fixtures.
- [x] Derive fixed workspace change and verification evidence from an absent-before result, exact expected content, and an actually executed verifier.
- [x] Guarantee raw capture cleanup on success/failure/interruption and publish only a validated redacted manifest through same-directory atomic rename.
- [x] Run dependency, syntax, credential-free behavior, Make entry point, model-binding inventory, aggregate isolation, cleanup/publication, and diff verification freshly without claiming S12 qualification.
- [x] 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-owned-single-request-agent-execution/24+22_claude_smoke_harness/` to `agent-task/archive/YYYY/MM/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/` and update this checklist at the final archive path.
- [ ] If PASS, preserve and report `milestone-task=claude-smoke` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-iop-owned-single-request-agent-execution/` 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

None. The implementation remained within the script, closed manifest schema, and implementation-owned review fields. No production runtime, Make target, contract, spec, roadmap, credential, deployment, or actual Claude/Mac execution was changed or performed.

## Key Design Decisions

- Runtime evidence is a closed snapshot with source branch/HEAD/worktree facts; actual runner and declared Darwin workspace-owner facts; canonical workspace, CLI, Edge, config-check, schema, base URL, public-model, and stage-engine digests. The workspace-owner digest binds the Darwin owner declaration, canonical workspace digest, and checked config. The stage-binding digest is recomputed from config/config-check, base, public model, and the validated engine tuple.
- Preflight captures bounded Claude version/help, Edge version, and `iop-edge config check` output without printing raw values. It also probes health, Messages, metrics, one append-only observation file, secret-name/value presence, absent result/output targets, and publication writability before the child marker can advance. The self-test covers one positive preflight and a table of 38 zero-child contradictions. Only the credential-free self-test uses a format-validated fixed worktree digest seam so concurrent sibling changes in the shared checkout cannot trip the fake suite; external preflight/run always computes the selected source worktree digest directly.
- The child receives the public model only through `ANTHROPIC_MODEL`. Runtime evidence, source, binaries, config, schema, workspace, and command-output digests are checked again after the invocation before fresh observation evidence is accepted.
- Workspace evidence requires `smoke-result.txt` to be absent before invocation, requires a changed deterministic workspace digest, and executes `cmp` against one fixed expected line. The actual verifier status and verifier-command digest feed the manifest builder; no success value is invented by the builder.
- One validated run temporary directory owns bounded stdout/stderr, command captures, expected content, and fresh observation bytes under an `EXIT`/signal cleanup trap. The validated publication temporary is created in the final output directory, schema/redaction-validated, and published with the platform no-replace rename primitive (`renameat2(RENAME_NOREPLACE)` on Linux or `renamex_np(RENAME_EXCL)` on Darwin). Success, failure, stale/rotated evidence, verification failure, post-invocation snapshot mutation, concurrent target creation, and interruption fixtures assert no raw or partial artifact remains.
- The manifest builder selects exactly one complete correlation from concurrent append-only observation records and uses the request `total` duration plus the validated stage-engine tuple. The schema and validator keep every object closed and make workspace change, verifier success, engine order, owner binding, and stage binding internally checkable.

## Reviewer Checkpoints

- [ ] R1: the child receives `ANTHROPIC_MODEL`, base/model/config/stage facts are digest-bound to one runtime snapshot, and stage records consume validated engine facts rather than literals.
- [ ] R2: every declared runner/workspace/executable/help/version/config/listener/log/metric/source/secret/output fact is checked before the child marker can advance, with redacted failures.
- [ ] R3: the result is absent before the run, the workspace changes, exact fixed content is verified, and the manifest records the actual verifier outcome.
- [ ] R4: success, failure, stale, rotated, verification-failure, and interruption cases leave no raw capture or partial output; successful publication is same-directory and atomic.
- [ ] The schema is closed at every object and carries only digest/closed facts with zero forbidden matches.
- [ ] Existing Make targets remain isolated and the packet changes no production runtime, contract, spec, roadmap, or test-rule document.
- [ ] No external Claude/Mac S12 qualification is claimed.

## Verification Results

Paste actual stdout/stderr for every command. If a command changes, record the replacement and reason in `Deviations from Plan` first. External invocation is not part of this packet.

### TEST-1 intermediate

```sh
./scripts/e2e-single-request-claude.sh --self-test
```

Output:

```text
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### TEST-2 intermediate

```sh
bash -n scripts/e2e-single-request-claude.sh && ./scripts/e2e-single-request-claude.sh --self-test
```

Output:

```text
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### TEST-3 intermediate

```sh
./scripts/e2e-single-request-claude.sh --self-test
```

Output:

```text
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### TEST-4 intermediate

```sh
make test-single-request-claude-smoke-self-test
```

Output:

```text
./scripts/e2e-single-request-claude.sh --self-test
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### Final 1 — dependency

```sh
bash -c 'set -euo pipefail; shopt -s nullglob; candidates=(agent-task/m-iop-owned-single-request-agent-execution/22_*/complete.log agent-task/m-iop-owned-single-request-agent-execution/22+*/complete.log agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/22_*/complete.log agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/22+*/complete.log); printf "%s\n" "${candidates[@]}"; ((${#candidates[@]} == 1))'
```

Output:

```text
agent-task/archive/2026/08/m-iop-owned-single-request-agent-execution/22+21_executor_activation/complete.log
Exit status: 0
```

### Final 2 — shell syntax

```sh
bash -n scripts/e2e-single-request-claude.sh
```

Output:

```text
(no stdout/stderr)
Exit status: 0
```

### Final 3 — credential-free behavior

```sh
./scripts/e2e-single-request-claude.sh --self-test
```

Output:

```text
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### Final 4 — Make entry point

```sh
make test-single-request-claude-smoke-self-test
```

Output:

```text
./scripts/e2e-single-request-claude.sh --self-test
[single-request-claude-smoke] self-test passed: model/runtime binding, zero-child preflight, derived verification, redaction, cleanup, signal handling, and atomic publication
Exit status: 0
```

### Final 5 — model and verifier inventory

```sh
bash -c "set -euo pipefail; rg --fixed-strings 'ANTHROPIC_MODEL=\"\$MODEL\"' scripts/e2e-single-request-claude.sh; ! rg --fixed-strings 'IOP_SINGLE_REQUEST_SMOKE_MODEL=\"\$MODEL\"' scripts/e2e-single-request-claude.sh; ! rg --fixed-strings \"'exit_code':0\" scripts/e2e-single-request-claude.sh"
```

Output:

```text
      ANTHROPIC_MODEL="$MODEL" \
Exit status: 0
```

### Final 6 — target/input inventory

```sh
rg --sort path -n 'test-single-request-claude-smoke|IOP_SINGLE_REQUEST_SMOKE_' Makefile
```

Output:

```text
1:.PHONY: all build build-local build-edge build-edge-host build-node build-node-target build-node-targets pack-node-target pack-edge archive-edge tidy test test-e2e test-control-plane-edge-wire test-credential-slot-smoke test-openai-ollama test-openai-lemonade test-openai-glm-coding test-hot-path-agent-smoke-self-test test-hot-path-agent-smoke-preflight test-hot-path-agent-smoke test-single-request-claude-smoke-self-test test-single-request-claude-smoke-preflight test-single-request-claude-smoke-validate test-single-request-claude-smoke readability-audit proto proto-dart client-test client-build-web clean
195:# Required caller inputs: IOP_SINGLE_REQUEST_SMOKE_CLAUDE_BIN,
196:# IOP_SINGLE_REQUEST_SMOKE_RUNTIME_EVIDENCE, IOP_SINGLE_REQUEST_SMOKE_BASE_URL,
197:# IOP_SINGLE_REQUEST_SMOKE_MODEL, IOP_SINGLE_REQUEST_SMOKE_EDGE_BIN,
198:# IOP_SINGLE_REQUEST_SMOKE_EDGE_CONFIG, IOP_SINGLE_REQUEST_SMOKE_OBSERVATION_FILE,
199:# IOP_SINGLE_REQUEST_SMOKE_METRICS_URL, IOP_SINGLE_REQUEST_SMOKE_WORKSPACE,
200:# IOP_SINGLE_REQUEST_SMOKE_OUTPUT, and IOP_SINGLE_REQUEST_SMOKE_SECRET_ENV.
202:test-single-request-claude-smoke-self-test:
205:test-single-request-claude-smoke-preflight:
207:		--claude "$(IOP_SINGLE_REQUEST_SMOKE_CLAUDE_BIN)" \
208:		--runtime-evidence "$(IOP_SINGLE_REQUEST_SMOKE_RUNTIME_EVIDENCE)" \
209:		--base-url "$(IOP_SINGLE_REQUEST_SMOKE_BASE_URL)" \
210:		--model "$(IOP_SINGLE_REQUEST_SMOKE_MODEL)" \
211:		--edge-bin "$(IOP_SINGLE_REQUEST_SMOKE_EDGE_BIN)" \
212:		--edge-config "$(IOP_SINGLE_REQUEST_SMOKE_EDGE_CONFIG)" \
213:		--observation-file "$(IOP_SINGLE_REQUEST_SMOKE_OBSERVATION_FILE)" \
214:		--metrics-url "$(IOP_SINGLE_REQUEST_SMOKE_METRICS_URL)" \
215:		--workspace "$(IOP_SINGLE_REQUEST_SMOKE_WORKSPACE)" \
216:		--output "$(IOP_SINGLE_REQUEST_SMOKE_OUTPUT)" \
217:		--secret-env "$(IOP_SINGLE_REQUEST_SMOKE_SECRET_ENV)"
219:test-single-request-claude-smoke-validate:
220:	./scripts/e2e-single-request-claude.sh --validate-manifest "$(IOP_SINGLE_REQUEST_SMOKE_OUTPUT)"
222:test-single-request-claude-smoke:
224:		--claude "$(IOP_SINGLE_REQUEST_SMOKE_CLAUDE_BIN)" \
225:		--runtime-evidence "$(IOP_SINGLE_REQUEST_SMOKE_RUNTIME_EVIDENCE)" \
226:		--base-url "$(IOP_SINGLE_REQUEST_SMOKE_BASE_URL)" \
227:		--model "$(IOP_SINGLE_REQUEST_SMOKE_MODEL)" \
228:		--edge-bin "$(IOP_SINGLE_REQUEST_SMOKE_EDGE_BIN)" \
229:		--edge-config "$(IOP_SINGLE_REQUEST_SMOKE_EDGE_CONFIG)" \
230:		--observation-file "$(IOP_SINGLE_REQUEST_SMOKE_OBSERVATION_FILE)" \
231:		--metrics-url "$(IOP_SINGLE_REQUEST_SMOKE_METRICS_URL)" \
232:		--workspace "$(IOP_SINGLE_REQUEST_SMOKE_WORKSPACE)" \
233:		--output "$(IOP_SINGLE_REQUEST_SMOKE_OUTPUT)" \
234:		--secret-env "$(IOP_SINGLE_REQUEST_SMOKE_SECRET_ENV)"
Exit status: 0
```

### Final 7 — aggregate isolation

```sh
bash -c 'set -euo pipefail; if rg --sort path -n "test-single-request-claude-smoke([^:]*):.*test-single-request-claude-smoke$" Makefile; then exit 1; else test $? -eq 1; fi'
```

Output:

```text
(no stdout/stderr)
Exit status: 0
```

### Final 8 — diff

```sh
git diff --check
```

Output:

```text
(no stdout/stderr)
Exit status: 0
```

---

> **[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) |
| 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:
  - Correctness: Fail — the manifest serializes the request-start observation's zero duration instead of the production terminal observation's request-total duration, the Messages preflight accepts a missing route, and interruption cleanup can wait forever on one child PID.
  - Completeness: Fail — the required stage/total timing, fail-before-invocation Messages route check, and guaranteed interruption cleanup are not fully implemented.
  - Test Coverage: Fail — the self-test reverses the production duration placement, has no 404 route-negative case, and tests only a TERM-cooperative direct child.
  - API Contract: Fail — a 404 `/v1/messages` response passes preflight, so the harness can invoke Claude without proving the Anthropic Messages route exists.
  - Code Quality: Fail — signal cleanup sends TERM to one PID and performs an unbounded `wait`, without process-group ownership or kill escalation.
  - Implementation Deviation: Fail — mandatory stage/total evidence and all-interruption cleanup were implemented against fake-only assumptions that differ from the production producer and adversarial process lifecycle.
  - Verification Trust: Fail — all recorded commands pass, but the fake emits total duration on the request record while production emits it on the terminal record, so the passing suite does not exercise the actual evidence contract.
  - Spec Conformance: Fail — SDD S12 requires reproducible stage/total timing and a real one-request Anthropic route; the current manifest and preflight cannot establish both.
- Findings:
  - Required R1 — `scripts/e2e-single-request-claude.sh:812`: `build_manifest` reads `duration_ms` from the initial `request/total` record and writes that value as `terminal.duration_ms`, while the production producer emits the initial request record without `DurationMS` (`apps/edge/internal/service/single_request_observation.go:644`) and puts the actual request total on the terminal record (`apps/edge/internal/service/single_request_observation.go:629-638`). Every real run therefore publishes zero total duration and discards the validated terminal duration at line 816. Read the total from the successful terminal record, require the terminal's closed success/result facts, make the fake match production (`request=0`, `terminal=total`), and assert the published total equals the terminal observation.
  - Required R2 — `scripts/e2e-single-request-claude.sh:625`: the Messages probe accepts every 2xx, 3xx, or 4xx response, including 404; a server with no `/v1/messages` route therefore passes preflight and advances the Claude child marker. The current Edge route deterministically returns 401 when auth rejects the unauthenticated probe or 405 after the route reaches the method guard. Restrict the probe to those route-proving statuses and add a 404 zero-child fixture.
  - Required R3 — `scripts/e2e-single-request-claude.sh:445`: interruption cleanup sends TERM only to `CHILD_PID` and immediately performs an unbounded `wait`. A Claude process that ignores TERM, or a descendant outside direct-PID ownership, can hang the harness and prevent raw capture deletion. Give the child a dedicated process group/session, use bounded TERM-to-KILL escalation with a reaped supervisor, and add ignored-TERM plus descendant cleanup fixtures that prove bounded exit and no raw/partial artifacts.
- Routing Signals:
  - `review_rework_count=2`
  - `evidence_integrity_failure=false`
- Next Step: Invoke the plan skill with Required findings R1-R3, route the smallest repository-fixable follow-up, and do not write `complete.log`.
