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

## Archive Evidence Snapshot

- Reviewed plan: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/plan_cloud_G08_3.log`; reviewed implementation/review: `agent-task/m-iop-owned-single-request-agent-execution/24+22_claude_smoke_harness/code_review_cloud_G09_3.log`; earlier loop evidence remains in the same task directory.
- Verdict: FAIL. Required R3 remains open because normal direct-child exit does not settle the process group, the spawn/assignment signal window can exit without fencing the child, and the readiness fixture reads the descendant PID path before proving it exists.
- Fresh review evidence: dependency, shell syntax, model/verifier inventory, target inventory, aggregate isolation, and `git diff --check` passed. Direct self-test executions produced two `unexpected self-test failure` results and one pass; the Make self-test target failed. A focused process-group reproduction returned `direct_status=0 descendant_alive_after_direct_exit=true`.
- Roadmap carryover: `milestone-task=claude-smoke` maps to approved SDD S12. This packet repairs only the credential-free cleanup 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_4.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_4.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 and task group is `m-<milestone-slug>`, preserve the first-line `milestone-task` metadata in `complete.log` and report it for the runtime aggregation event. 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 |
|------|---------|
| REVIEW_TEST-1 Close every supervisor process-group exit path | [x] |
| REVIEW_TEST-2 Make cleanup regressions deterministic | [x] |

## Implementation Checklist

- [x] Settle the Claude process group with one bounded normal/failure/signal lifecycle, preserve the direct exit status only after group closure, and close the pre-assignment signal window.
- [x] Make descendant readiness race-safe and add deterministic leader-exit-with-descendant and early-signal regressions that prove bounded exit, no surviving process, no raw capture, and no partial/final publication.
- [x] Run dependency, syntax, three fresh self-tests, Make self-test, process-coverage inventory, model/verifier inventory, target inventory, aggregate isolation, and diff verification 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_4.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_4.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`.
- [x] If PASS, write `complete.log` based on `agent-ops/skills/common/code-review/templates/complete-log-template.md` and leave no active `.md` files.
- [x] 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.
- [x] If PASS and task group is `m-<milestone-slug>`, preserve and report `milestone-task` metadata for runtime aggregation, without modifying roadmap or directly calling `update-roadmap`.
- [x] 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.
- [ ] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

None. The plan's two-file write boundary, lifecycle strategy, fixture families, and verification commands were preserved.

## Key Design Decisions

- The embedded supervisor records a signal received before `Popen` ownership is published, then applies the same bounded TERM-to-KILL process-group settlement immediately after assignment.
- Every normal, non-zero, and signal path calls `settle_group()` before returning its direct-child status or signal exit status. Settlement checks process-group existence rather than only the leader's poll state.
- Credential-free fixtures initialize and safely parse the descendant PID path. `leader-exit` leaves a TERM-resistant descendant after direct success; `early-signal` uses a self-test-only pre-exec signal seam; both assert bounded cleanup and no raw or published artifact.

## Reviewer Checkpoints

- [x] R3: normal, non-zero, and signal exits share one bounded process-group settlement path and the direct status is returned only after no group member remains.
- [x] R3: an early signal cannot exit between process creation and published ownership without fencing the new group.
- [x] R3: leader-exit, early-signal, and TERM-resistant fixtures have race-safe readiness and prove no descendant, raw capture, partial publication, or final manifest remains when interruption/failure applies.
- [x] The corrected production-faithful terminal timing and 401/405 Messages route fence remain covered.
- [x] The schema, Make targets, production Edge/Node runtime, contracts, specs, and roadmap are unchanged.
- [x] 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.

### REVIEW_TEST-1 intermediate

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

Output:

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

### REVIEW_TEST-2 intermediate

```sh
bash -c 'set -euo pipefail; for attempt in 1 2 3; do ./scripts/e2e-single-request-claude.sh --self-test; done'
```

Output:

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

### 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
Exit status: 0
stdout/stderr: (empty)
```

### Final 3 — repeated credential-free behavior

```sh
bash -c 'set -euo pipefail; for attempt in 1 2 3; do ./scripts/e2e-single-request-claude.sh --self-test; done'
```

Output:

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

### 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 — process lifecycle inventory

```sh
bash -c "set -euo pipefail; rg --sort path -n 'leader-exit|early-signal|term-resistant|descendant' scripts/e2e-single-request-claude.sh; ! rg --fixed-strings 'raise SystemExit(child.wait())' scripts/e2e-single-request-claude.sh"
```

Output:

```text
1141:if [ "$behavior" = 'leader-exit' ];then
1146:if [ "$behavior" = 'term-resistant' ] || [ "$behavior" = 'early-signal' ];then
1251:    descendant = root / "descendant"
1252:    descendant.write_text("")
1299:        "descendant": descendant,
1336:        "IOP_SMOKE_FAKE_DESCENDANT": str(fixture["descendant"]),
1381:def require_descendant_pid(fixture, case):
1383:    descendant = fixture["descendant"]
1385:        if descendant.exists():
1386:            value = descendant.read_text().strip()
1391:                    raise TestFailure(case + ": descendant PID was invalid")
1393:    raise TestFailure(case + ": descendant did not start")
1403:    raise TestFailure(case + ": descendant remained")
1594:            leader_exit_fixture = create_fixture(suite, "run-leader-exit", base_url)
1606:            early_signal_fixture = create_fixture(suite, "run-early-signal", base_url)
1623:            signal_fixture = create_fixture(suite, "run-term-resistant", base_url)
Exit status: 0
```

### Final 6 — 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 7 — 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 8 — 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
Exit status: 0
stdout/stderr: (empty)
```

### Final 9 — diff

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

Output:

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

---

> **[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: PASS
- Dimension Assessment:
  - Correctness: Pass — normal, non-zero, and signal exits now use the same bounded process-group settlement, and direct status is returned only after group closure.
  - Completeness: Pass — the pre-assignment signal window, leader-exit descendant lifecycle, readiness race, and raw/publication cleanup requirements are all closed.
  - Test Coverage: Pass — deterministic leader-exit, early-signal, and TERM-resistant fixtures cover bounded cleanup and absence of surviving current-run processes and artifacts.
  - API Contract: Pass — the production-faithful terminal duration source, 401/405 Messages route fence, public model binding, and derived verifier evidence remain covered.
  - Code Quality: Pass — lifecycle ownership is centralized in one idempotent TERM-to-KILL settlement routine with bounded waits and explicit failure.
  - Implementation Deviation: Pass — the implementation stayed within the two-file write boundary and followed the planned lifecycle and fixture strategy.
  - Verification Trust: Pass — all nine final commands passed freshly; the reviewer corrected only the stale stdout/stderr summaries to match the observed success log lines.
  - Spec Conformance: Pass — the credential-free harness now protects SDD S12 cleanup and evidence preconditions without claiming actual Claude/Mac qualification.
- Findings: None
- Routing Signals:
  - `review_rework_count=3`
  - `evidence_integrity_failure=false`
- Next Step: PASS — write `complete.log`, archive the active pair and task directory, and report `milestone-task=claude-smoke` for runtime aggregation.
