<!-- task=m-node-provider-execution-liveness-recovery/10+09_stall_recovery plan=11 tag=REVIEW_TEST milestone-task=bounded-retry -->

# 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-06
task=m-node-provider-execution-liveness-recovery/10+09_stall_recovery, plan=11, tag=REVIEW_TEST

## Archive Evidence Snapshot

- The reviewed plan=10 pair is archived in this task directory as `plan_cloud_G03_10.log` and `code_review_cloud_G03_10.log` with verdict `FAIL`.
- Required R1: normalized attempt-B assertions accept substituted non-empty prompt/input, non-negative queue values, and broadly valid estimate/context values instead of proving the fixture's concrete request context.
- Fresh reviewer reruns passed all twelve declared commands; source review showed the production overlay is correct and the remaining defect is assertion sensitivity.
- Routing signals are `review_rework_count=8` and `evidence_integrity_failure=false`.

## 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-G03.md` → `code_review_cloud_G03_11.log` and `PLAN-cloud-G03.md` → `plan_cloud_G03_11.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-node-provider-execution-liveness-recovery/10+09_stall_recovery/`. 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 Make normalized attempt-B assertions value-sensitive | [x] |

## Implementation Checklist

- [x] REVIEW_TEST-1 replaces permissive normalized Responses attempt-B predicates with exact fixture-value assertions for prompt, input, required metadata, timeout, queue values, token estimate, and context class while retaining both cross-path directions and every lifecycle assertion.
- [x] Run and record every exact final verification command separately after REVIEW_TEST-1 is complete.
- [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_G03_11.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G03_11.log`.
- [x] Verify that the Agent-Ops managed block unignores task Markdown/log artifacts 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-node-provider-execution-liveness-recovery/10+09_stall_recovery/` to `agent-task/archive/YYYY/MM/m-node-provider-execution-liveness-recovery/10+09_stall_recovery/` 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-node-provider-execution-liveness-recovery/` 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 exact fixture-value assertions were implemented as planned, with chat/responses endpoint prompt and token estimate differences properly handled.

## Key Design Decisions

Exact assertions in `TestOpenAIStallRecoveryMatrix` enforce concrete prompt/input values (`"user: hi"` / `"hi"`), metadata entries (`strict_output`=`"false"`, `estimated_input_tokens`=`"7"` or `"2"`, `context_class`=`"normal"`), queue fields `(0,0)`, and estimated token count/context class.

## Reviewer Checkpoints

- The normalized Responses replacement asserts `Prompt == "hi"` and `Input["prompt"] == "hi"` rather than only non-empty values.
- The normalized replacement asserts model, stream, strict-output, estimated-token, and context metadata values exactly.
- Timeout, queue fields, token estimate, and context class are checked against the deterministic fixture values `5`, `(0,0)`, `7`, and `"normal"`.
- The direction-specific last request remains the attempt-B request for both tunnel-to-normalized and normalized-to-tunnel rows.
- Provider avoidance, distinct attempt identities, two admissions, exactly-once transport closes, sanitized output, and one public terminal remain asserted.
- Production source, shared test support, contracts, specs, config, proto, and smoke scripts remain unchanged.
- All twelve final verification outputs are complete fresh invocations.

## Verification Results

Paste complete stdout/stderr for each exact command. Do not summarize or combine command results.

### Verification 1

Command:

```bash
go test -count=10 ./apps/edge/internal/openai -run 'TestOpenAIStallRecoveryMatrix/recover/responses/(provider_tunnel_to_normalized|normalized_to_provider_tunnel)'
```

Output:

```text
ok  	iop/apps/edge/internal/openai	0.065s
```

### Verification 2

Command:

```bash
go test -count=10 ./apps/edge/internal/openai -run '^TestOpenAIStallRecoveryMatrix$'
```

Output:

```text
ok  	iop/apps/edge/internal/openai	0.107s
```

### Verification 3

Command:

```bash
go test -count=10 ./apps/edge/internal/openai -run '^TestOpenAISemanticGateDisabledCompatibility$'
```

Output:

```text
ok  	iop/apps/edge/internal/openai	0.071s
```

### Verification 4

Command:

```bash
go test -count=20 ./apps/edge/internal/openai -run '^(TestOpenAIStallRecoveryFilter|TestOpenAIAttemptControllerConfirmedStall|TestOpenAIAttemptDispatcherStalledProvider)$'
```

Output:

```text
ok  	iop/apps/edge/internal/openai	0.055s
```

### Verification 5

Command:

```bash
go test -count=1 ./packages/go/streamgate ./apps/edge/internal/openai ./apps/edge/internal/service ./apps/edge/internal/controlplane
```

Output:

```text
ok  	iop/packages/go/streamgate	0.917s
ok  	iop/apps/edge/internal/openai	7.641s
ok  	iop/apps/edge/internal/service	6.031s
ok  	iop/apps/edge/internal/controlplane	6.676s
```

### Verification 6

Command:

```bash
go test -race -count=3 ./apps/edge/internal/service
```

Output:

```text
ok  	iop/apps/edge/internal/service	19.243s
```

### Verification 7

Command:

```bash
go test -race -count=3 ./apps/edge/internal/openai
```

Output:

```text
ok  	iop/apps/edge/internal/openai	25.585s
```

### Verification 8

Command:

```bash
go vet ./packages/go/streamgate ./apps/edge/internal/service ./apps/edge/internal/openai ./apps/edge/internal/controlplane
```

Output:

```text
```

### Verification 9

Command:

```bash
./scripts/e2e-smoke.sh
```

Output:

```text
[e2e] verifying provider-only Node command and cancellation boundary
ok  	iop/apps/node/internal/node	0.051s
[e2e] verifying Edge dispatch, provider tunnel, queue, and reconnect fencing
ok  	iop/apps/edge/internal/service	4.435s
ok  	iop/apps/edge/internal/transport	0.267s
[e2e] provider-only Edge-Node smoke PASSED
```

### Verification 10

Command:

```bash
IOP_VLLM_MODE=fake ./scripts/e2e-openai-vllm.sh
```

Output:

```text
[openai-vllm] OpenAI-compatible vLLM serving test PASSED (mode=fake).
```

### Verification 11

Command:

```bash
./scripts/e2e-provider-capacity-smoke.sh
```

Output:

```text
[provider-capacity-smoke] tmp_root=/config/tmp/gocache-secure-delivery
[provider-capacity-smoke] building loopback binaries
[provider-capacity-smoke] metrics=disabled bounded_probe_timeout_sec=2
[provider-capacity-smoke] offline_snapshot_rejected=true
[provider-capacity-smoke] aliases=ornith:35b,ornith-fast queue_observed=true
[provider-capacity-smoke] backend={"calls":2,"active":0,"peak":1}
[provider-capacity-smoke] final_provider=[{"node_id":"ornith-node","connected":true,"providers":[{"id":"ornith-provider","status":"available","health":"available","capacity":1,"in_flight":0,"queued":0,"long_context_capacity":1,"long_in_flight":0,"long_queued":0}]}]
[provider-capacity-smoke] PASS evidence=/config/tmp/gocache-secure-delivery/iop-provider-capacity-smoke.Kk0IE0
```

### Verification 12

Command:

```bash
git diff --check
```

Output:

```text
```

---

> **[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 — the normalized replacement assertions now compare the recorded attempt-B request against the deterministic Chat and Responses fixture values while preserving direction-specific request selection and lifecycle checks.
  - Completeness: Pass — REVIEW_TEST-1 is implemented, every implementation-owned checklist item is complete, and the previous Required R1 is closed by exact prompt, input, metadata, timeout, queue, estimate, and context assertions.
  - Test Coverage: Pass — the production-handler matrix remains sensitive to substituted normalized request values across both Responses path-switch directions and both semantic modes, and the surrounding same-path, guard, budget, close, and terminal rows remain intact.
  - API Contract: Pass — the assertions agree with the current Responses-to-normalized `RunRequest` contract and do not change the public OpenAI-compatible surface or the Edge-Node wire.
  - Code Quality: Pass — the change is localized to the existing matrix oracle, formatted, and introduces no stale symbol, debug output, dead branch, or unrelated source change.
  - Implementation Deviation: Pass — the implementation follows the direct-fix boundary; its additional exact Chat expectations use the same fixture-aware oracle without expanding production behavior.
  - Verification Trust: Pass — all twelve declared commands passed on fresh reviewer runs, including focused repetition, package and race suites, vet, deterministic smoke paths, and whitespace validation.
  - Spec Conformance: Pass — the production-handler evidence now proves SDD S05 request-context preservation together with recovery-owner gating, provider avoidance, new attempt identity, bounded dispatch, exactly-once transport close, and one public terminal.
- Findings: None.
- Routing Signals:
  - `review_rework_count=8`
  - `evidence_integrity_failure=false`
- Reviewer Verification:
  - `go test -count=10 ./apps/edge/internal/openai -run 'TestOpenAIStallRecoveryMatrix/recover/responses/(provider_tunnel_to_normalized|normalized_to_provider_tunnel)'` — PASS (`ok`, 0.096s).
  - `go test -count=10 ./apps/edge/internal/openai -run '^TestOpenAIStallRecoveryMatrix$'` — PASS (`ok`, 0.131s).
  - `go test -count=10 ./apps/edge/internal/openai -run '^TestOpenAISemanticGateDisabledCompatibility$'` — PASS (`ok`, 0.116s).
  - `go test -count=20 ./apps/edge/internal/openai -run '^(TestOpenAIStallRecoveryFilter|TestOpenAIAttemptControllerConfirmedStall|TestOpenAIAttemptDispatcherStalledProvider)$'` — PASS (`ok`, 0.233s).
  - `go test -count=1 ./packages/go/streamgate ./apps/edge/internal/openai ./apps/edge/internal/service ./apps/edge/internal/controlplane` — PASS.
  - `go test -race -count=3 ./apps/edge/internal/service` — PASS with no race report.
  - `go test -race -count=3 ./apps/edge/internal/openai` — PASS with no race report.
  - `go vet ./packages/go/streamgate ./apps/edge/internal/service ./apps/edge/internal/openai ./apps/edge/internal/controlplane` — PASS with no diagnostics.
  - `./scripts/e2e-smoke.sh` — PASS.
  - `IOP_VLLM_MODE=fake ./scripts/e2e-openai-vllm.sh` — PASS.
  - `./scripts/e2e-provider-capacity-smoke.sh` — PASS.
  - `git diff --check` — PASS.
- Next Step: PASS — archive the active pair, write `complete.log`, and move the split task directory to the 2026/08 task archive without modifying the roadmap.
