<!-- task=m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness plan=3 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=3, tag=REVIEW_TEST

## Archive Evidence Snapshot

- Reviewed plan: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/plan_cloud_G10_2.log`; reviewed implementation/review: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/code_review_cloud_G10_2.log`; earlier loop evidence remains `plan_cloud_G07_0.log`, `code_review_cloud_G07_0.log`, `plan_cloud_G07_1.log`, and `code_review_cloud_G07_1.log` in the same task directory.
- Verdict: FAIL. Required R1 found that the harness discards the production terminal's actual request-total duration and serializes the request-start zero. Required R2 found that 404 proves no Messages route but still passes preflight. Required R3 found unbounded direct-PID TERM cleanup without process-group ownership or kill escalation.
- Fresh review verification passed dependency resolution, shell syntax, the current self-test, the Make self-test target, model/verifier inventory, target inventory, aggregate isolation, and `git diff --check`. Static producer/harness comparison proved the duration-source mismatch, and the current status regex accepted 404.
- Roadmap carryover: `milestone-task=claude-smoke` maps to approved SDD S12. This packet repairs the credential-free harness oracle and must not claim 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-G09.md` → `code_review_cloud_G09_3.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_3.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 Use the production terminal as the total-time source | [x] |
| TEST-2 Prove the Messages route before invocation | [x] |
| TEST-3 Bound and reap interruption cleanup | [x] |

## Implementation Checklist

- [x] Read total duration from the successful production terminal observation, require its closed result facts, and make the self-test assert production-faithful timing projection.
- [x] Reject 404 and every non-401/non-405 Messages probe result before child invocation, with a zero-child missing-route fixture.
- [x] Supervise Claude in a dedicated process group/session with bounded TERM-to-KILL escalation and prove ignored-TERM plus descendant cleanup.
- [x] Run dependency, syntax, credential-free behavior, Make entry point, model/verifier inventory, target inventory, aggregate isolation, 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_G09_3.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_3.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 selected harness, its embedded credential-free fixtures, and the review evidence file are the only modified task-owned files.

## Key Design Decisions

- The request lifecycle record remains the one-ingress marker and is required to have production-shaped `duration_ms=0`; the successful terminal record must carry `has_result=true` and supplies the manifest total duration.
- The preflight accepts only the current unauthenticated route-proving outcomes, `401` and `405`. The embedded listener proves that `401` passes while `404` and `503` stop before the fake Claude child starts.
- A Python supervisor owns the Claude process in a new session. On interruption it sends process-group TERM, waits two seconds, sends process-group KILL if needed, and reaps the direct child. Shell cleanup separately bounds supervisor termination. The fixture waits for a TERM-resistant descendant to start before interrupting it, avoiding a readiness race while proving no descendant, capture directory, partial publication, or final manifest remains.

## Reviewer Checkpoints

- [ ] R1: the manifest total comes from the successful terminal observation, requires `has_result=true`, and the fake uses request duration 0 plus a distinct terminal total.
- [ ] R2: only 401 or 405 proves the current Messages route, while 404/503 fail before the child marker changes.
- [ ] R3: Claude and descendants are process-group owned, TERM resistance escalates within a fixed bound, every process is reaped, and no raw/partial artifact remains.
- [ ] The schema, Make targets, production Edge/Node runtime, contracts, specs, and roadmap are unchanged.
- [ ] 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=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=0
```

### TEST-3 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=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=0
```

### Final 2 — shell syntax

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

Output:

```text
(no output)
exit=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=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=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=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:
219:test-single-request-claude-smoke-validate:
222:test-single-request-claude-smoke:
exit=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 output; no aggregate target depends on the credentialed target)
exit=0
```

### Final 8 — diff

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

Output:

```text
(no output)
exit=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 supervisor returns as soon as the direct Claude process exits and can leave a same-session descendant running; a signal received while `Popen` is creating the child can also exit before the child is assigned and fenced.
  - Completeness: Fail — R3's complete process-group ownership and reap requirement is not closed on every supervisor exit path.
  - Test Coverage: Fail — the TERM-resistant fixture reads the descendant PID file before proving that the file exists, and it has no case for a leader that exits while a descendant remains.
  - API Contract: Pass — the terminal timing source and 401/405 Messages route fence now match the production observations and route behavior covered by this packet.
  - Code Quality: Fail — normal completion and signal cleanup use different lifecycle paths, leaving process-group settlement outside the direct-child success path.
  - Implementation Deviation: Fail — the plan required Claude and every descendant to remain process-group owned and fully settled, but the implementation only tears down the group from the signal handler.
  - Verification Trust: Fail — two fresh executions of the claimed passing self-test failed with `unexpected self-test failure`, including the Make target, while one retry passed; the recorded deterministic PASS evidence is contradicted by current reviewer output.
  - Spec Conformance: Fail — SDD S12 evidence cannot be trusted while the harness has a nondeterministic cleanup fixture and may leave request-owned child processes after a nominal run.
- Findings:
  - Required R3 — `scripts/e2e-single-request-claude.sh:786`: the supervisor exits with the direct child's status without settling the child process group, so a direct child that exits after starting a TERM-resistant background descendant leaves that descendant alive; a focused reproduction returned `direct_status=0 descendant_alive_after_direct_exit=true`. The same lifecycle is still racy at lines 753-771 because a signal delivered during `Popen` before `child` assignment raises `SystemExit` without fencing the newly created group. The regression fixture is itself nondeterministic at lines 1191 and 1520: `descendant` is only a path, but `read_text()` is called before checking existence, which produced two fresh `unexpected self-test failure` results while one retry passed. Unify normal, failure, and signal exit through one bounded process-group settlement path, close the pre-assignment signal window, initialize or existence-guard readiness evidence, and add deterministic leader-exit-with-descendant plus early-signal coverage.
- Routing Signals:
  - `review_rework_count=3`
  - `evidence_integrity_failure=true`
- Next Step: Invoke the plan skill with Required finding R3, route the smallest repository-fixable follow-up, and do not write `complete.log`.
