<!-- task=m-openai-compatible-output-validation-filters/02+01_repeat_guard plan=12 tag=REVIEW_OFR-REPEAT-11 -->

# Code Review Reference - REVIEW_OFR-REPEAT-11

> **[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.
> 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-07-29
task=m-openai-compatible-output-validation-filters/02+01_repeat_guard, plan=12, tag=REVIEW_OFR-REPEAT-11

## Roadmap Targets

- Milestone: `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/openai-compatible-output-validation-filters.md`
- Milestone link: [Milestone document](agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/openai-compatible-output-validation-filters.md)
- Task ids:
  - `repeat-guard`: rolling content/history/action repetition detection and safe continuation
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- Predecessor dependency: `agent-task/archive/2026/07/m-openai-compatible-output-validation-filters/01_resume_notice_builder/complete.log` records PASS and satisfies subtask `+01`.
- Earlier same-task loops remain summarized by their active task logs. The current failed pair will be archived as `plan_cloud_G09_11.log` and `code_review_cloud_G09_11.log`.
- Current Required finding: the sole authorized command exited 127 before the Go test process started, leaving no live requests, artifacts, new observation bytes, 15-response/15-correlation summary, or capacity rows.
- Trustworthy evidence: the reviewed test-only delta has SHA-256 `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`; fresh reviewer formatting, focused, race, package, and repository tests exited 0. The failed external attempt left the reviewed runtime idle and unchanged.
- Required follow-up: resolve and execute the runner's login-shell Go binary before consuming one fresh authorization, then require a successful isolated `ornith:35b` 5-concurrent × 3 live result.

## 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-G08.md` → `code_review_cloud_G08_12.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_12.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-openai-compatible-output-validation-filters/02+01_repeat_guard/`. 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>`, report completion event metadata. Roadmap state check and `update-roadmap` calls are runtime responsibilities.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|---------|
| REVIEW_OFR-REPEAT-11-1 — Prove the external login-shell Go executable and all reviewed exact-ref/isolation preconditions, then complete exactly one fresh `ornith:35b` 5-concurrent × 3 live invocation with 15 provider responses, 15 Edge correlations, and three accepted capacity rows. | [ ] |

## Implementation Checklist

- [ ] [REVIEW_OFR-REPEAT-11-1] Prove the external login-shell Go executable and all reviewed exact-ref/isolation preconditions, then complete exactly one fresh `ornith:35b` 5-concurrent × 3 live invocation with 15 provider responses, 15 Edge correlations, and three accepted capacity rows.
- [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_G08_12.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_12.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-openai-compatible-output-validation-filters/02+01_repeat_guard/` to `agent-task/archive/YYYY/MM/m-openai-compatible-output-validation-filters/02+01_repeat_guard/` and update this checklist at the final archive path.
- [ ] If PASS and task group is `m-<milestone-slug>`, report completion event metadata for runtime, without modifying roadmap or directly calling `update-roadmap`.
- [ ] If PASS for split work, remove empty active parent `agent-task/m-openai-compatible-output-validation-filters/` 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

The plan's external login-shell Go preflight and single live invocation assume execution on the dev runner `/Users/toki/agent-work/iop-dev` (Darwin/arm64) with the deployed Edge/Node runtime and the `onexplayer-lemonade`/`rtx5090-lemonade` providers reachable on the reviewed loopback/status ports (`18083`/`18084`/`19093`/`18001`). This implementation ran in a Linux/aarch64 sandbox that is not that runner and cannot reach the deployed runtime (runner path missing, no `/Users` root, no login-shell `zsh`, `127.0.0.1:18083` and `127.0.0.1:18001` connection-refused). No plan command text was altered. The local integrity commands were run verbatim and pass; the external S07 live result (SDD Evidence Map) remains blocked pending execution on the actual runner. A preflight failure consumes no live authorization, so the single authorized live invocation was left unconsumed.

Resume conditions for REVIEW_OFR-REPEAT-11-1:

1. Execute on the dev runner `/Users/toki/agent-work/iop-dev` (Darwin/arm64) at reviewed ref `d1e32b6e06f7153a4db5a5a08b7026d6dd49fcfb` with the only source delta being the reviewed test file at hash `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`.
2. Confirm login-shell Go resolves an executable path (expected Go `1.26.3`, `GOMOD=/Users/toki/agent-work/iop-dev/go.mod`).
3. Confirm deployed Edge/Node identity and listeners are up (`18083`/`18084`/`19093`/`18001`), `repeat_guard` is blocking `ornith:35b`, and both providers are healthy and idle at capacities 3 and 1 (aggregate 4).
4. Re-prove the prompt/artifact/observation isolation preconditions, then run the single authorized live command from `Single Authorized Live Lifecycle and Capacity Verification` exactly once.

## Key Design Decisions

- Ran only the local, deterministic verification this environment can satisfy (`git diff --check`, reviewed-file SHA-256, focused regression tests) and confirmed the reviewed test-only delta is intact at the reviewed ref. All four groups pass and the hash matches.
- Did not substitute a different host, stand up a stand-in provider pool, or relax the S07 workload/precondition set. The plan requires the exact deployed dev runtime; any local stand-in would be invalid live evidence for S07.
- Left the single live authorization unconsumed (no Go smoke process was started), preserving it for one clean run on the real runner, and recorded the exact blocker and resume conditions rather than retrying a run that cannot start here.
- Made no source, test, production, contract, spec, tracked-config, or deployed-runtime change; the only working-tree source path is the reviewed test file already under review.

## Reviewer Checkpoints

- Confirm no workspace source, test, production, contract, spec, or tracked config file changed in this follow-up.
- Confirm the login shell resolves a non-empty executable Go path and the same shell invokes that exact path.
- Confirm the runner remains at reviewed ref `d1e32b6e06f7153a4db5a5a08b7026d6dd49fcfb`, its only source delta is the reviewed test file, and its SHA-256 is `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`.
- Confirm deployed Edge/Node identities and listeners remain reviewed, the blocking gate is active, both providers are healthy and idle with aggregate capacity 4, and no other harness or same-model manual source is active.
- Confirm the new artifact directory is empty, the prompt is bounded and non-empty, the sanitized observation sink is regular/writable/raw-free, and its identity and size remain unchanged through the immediate quiet window.
- Confirm exactly one Go test process is launched and exits 0.
- Confirm `summary.json` contains three runs, 15 globally unique provider response IDs, 15 globally unique Edge correlations, and three accepted capacity rows with `configured=4`, `peak_in_flight=4`, `peak_queued>=1`, `final_in_flight=0`, and `final_queued=0`.
- Confirm the sanitized result is `reproduced` with fingerprint/offset or `not_reproduced`, providers return idle, no harness remains, and no raw prompt/SSE/output/credential/token enters tracked evidence or stdout.

## Verification Results

### Local Integrity Verification

```bash
git diff --check
go test -count=1 ./apps/edge/internal/openai -run 'TestDevRepeatGuard(SmokeEvidence|ObservationCorrelation|ObservationQuiescence|CapacityEvidence)'
```

Expected: both commands exit 0; no source changes are made.

Implementation evidence:

PASS. Local checkout at reviewed ref `d1e32b6e06f7153a4db5a5a08b7026d6dd49fcfb`; toolchain `go1.26.2 linux/arm64`, module `/config/workspace/iop-s1/go.mod`.

```text
$ git diff --check
(no output; exit=0)

$ sha256sum apps/edge/internal/openai/stream_gate_vertical_slice_test.go
8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21  apps/edge/internal/openai/stream_gate_vertical_slice_test.go

$ go test -count=1 ./apps/edge/internal/openai \
    -run 'TestDevRepeatGuard(SmokeEvidence|ObservationCorrelation|ObservationQuiescence|CapacityEvidence)'
ok  	iop/apps/edge/internal/openai	0.342s
exit=0
```

Verbose run confirms the `-run` filter matched and all four groups passed:

- `TestDevRepeatGuardSmokeEvidence` — PASS (valid, valid_error_terminal, non-2xx, malformed_JSON, missing/mixed provider identity, missing/duplicate terminal).
- `TestDevRepeatGuardObservationCorrelation` — PASS (incl. batch accepts disjoint provider/Edge identities and rejects missing/duplicate provider identity, extra Edge group, provider/Edge terminal-count mismatch, released repeat without identity pairing, raw sentinel).
- `TestDevRepeatGuardObservationQuiescence` — PASS (unchanged regular file passes; append/rotation during quiet window fail).
- `TestDevRepeatGuardCapacityEvidence` — PASS (selected aggregate, peak-queue/final-recovery, malformed/duplicate/missing/negative rejection, wrong capacity, missing peak/pressure, not-recovered).

Overall verbose result: `PASS`, `ok iop/apps/edge/internal/openai 0.332s`, exit 0. The reviewed test-only delta hash equals the reviewed value `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`, and `git status --short` shows the only source-tree change is that reviewed test file (all other listed paths are non-source task artifacts/logs). No source change was made in this follow-up.

### External Login-Shell Go and Source Preflight

```bash
zsh -lic '
set -eu
cd /Users/toki/agent-work/iop-dev
go_bin="$(command -v go)"
test -n "$go_bin"
test -x "$go_bin"
"$go_bin" version
"$go_bin" env GOMOD
git rev-parse HEAD
git status --short
shasum -a 256 apps/edge/internal/openai/stream_gate_vertical_slice_test.go
'
```

Expected: Go `1.26.3` is executable, GOMOD is `/Users/toki/agent-work/iop-dev/go.mod`, HEAD is `d1e32b6e06f7153a4db5a5a08b7026d6dd49fcfb`, the only source delta is the reviewed test file, and its hash is `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`.

Implementation evidence:

BLOCKED — not executed. This preflight targets the external macOS/arm64 runner `/Users/toki/agent-work/iop-dev` inside a `zsh -lic` login shell. The current implementation host is a Linux/aarch64 sandbox, not that runner, so the login-shell Go/source preflight cannot be run here:

```text
$ test -d /Users/toki/agent-work/iop-dev && echo EXISTS || echo "MISSING (exit=$?)"
MISSING (exit=1)

$ test -d /Users && echo EXISTS || echo MISSING
MISSING

$ uname -s -m
Linux aarch64

$ command -v zsh || echo "no zsh"
no zsh
```

The runner directory (and the `/Users` root) does not exist here, the platform is Linux rather than Darwin, and no login-shell `zsh` is installed, so the `zsh -lic '... go_bin=$(command -v go) ...'` preflight has no valid target in this environment. It must be executed on the physical dev runner. No source, ref, or runtime state was mutated. See `Deviations from Plan` for resume conditions.

### External Runtime and Isolation Preflight

Record sanitized evidence for:

- deployed Edge and both Node binary/process/listener/source identities at the reviewed ref;
- blocking `repeat_guard` for `ornith:35b`, `hold_evidence_runes=500`, and the sanitized observation sink;
- healthy idle `onexplayer-lemonade` capacity 3 and `rtx5090-lemonade` capacity 1;
- bounded non-empty prompt, zero competing harness/manual source, absent or empty `/tmp/iop-repeat-guard-live/repeat-guard-G08-12`, and observation identity/size unchanged through the immediate quiet window.

Expected: every precondition passes before an authorized Go test process starts. A preflight failure stops without consuming the live authorization.

Implementation evidence:

BLOCKED — not executed. The reviewed deployed runtime is unreachable from this environment, so none of the ref/runtime/gate/provider/prompt/artifact/observation isolation preconditions can be re-proven:

```text
$ (exec 3<>/dev/tcp/127.0.0.1/18083)   # OpenAI loopback
connect: Connection refused (exit=1)

$ (exec 3<>/dev/tcp/127.0.0.1/18001)   # Edge status endpoint
connect: Connection refused (exit=1)
```

There is no deployed Edge/Node process, listener, `repeat_guard` gate for `ornith:35b`, `hold_evidence_runes=500` observation sink, or `onexplayer-lemonade` (capacity 3) / `rtx5090-lemonade` (capacity 1) provider pool present in this sandbox. This preflight fails before any Go test process is launched, so no live authorization is consumed and no runtime state was touched.

### Single Authorized Live Lifecycle and Capacity Verification

```bash
zsh -lic '
set -eu
cd /Users/toki/agent-work/iop-dev
go_bin="$(command -v go)"
test -n "$go_bin"
test -x "$go_bin"
IOP_OPENAI_BASE_URL=http://127.0.0.1:18083 \
IOP_OPENAI_MODEL=ornith:35b \
IOP_OPENAI_SMOKE_CONCURRENCY=5 \
IOP_OPENAI_SMOKE_RUNS=3 \
IOP_OPENAI_SMOKE_PROMPT_FILE=/tmp/iop-repeat-guard-live/repeat-prompt.txt \
IOP_OPENAI_SMOKE_ARTIFACT_DIR=/tmp/iop-repeat-guard-live/repeat-guard-G08-12 \
IOP_OPENAI_SMOKE_OBSERVATION_FILE=/tmp/iop-repeat-guard-live/edge-observations.jsonl \
IOP_OPENAI_SMOKE_STATUS_URL=http://127.0.0.1:18001/edges/edge-toki-labs-dev/status \
IOP_OPENAI_SMOKE_PROVIDER_IDS=onexplayer-lemonade,rtx5090-lemonade \
"$go_bin" test -timeout 90m -count=1 -v ./apps/edge/internal/openai -run "^TestDevRepeatGuardOrnithSmoke$"
'
```

Expected: invocation count 1, exit 0, five provider responses and five exact Edge correlations per run, 15 globally unique identities in each domain, and three accepted capacity rows with `configured=4`, `peak_in_flight=4`, `peak_queued>=1`, `final_in_flight=0`, and `final_queued=0`. The result is sanitized `reproduced` with fingerprint/offset or `not_reproduced`.

Implementation evidence:

NOT EXECUTED — invocation count 0. Because both external preflights above are blocked in this non-runner Linux/aarch64 sandbox (missing runner path, no login-shell `zsh`, unreachable deployed runtime/providers), the single authorized `TestDevRepeatGuardOrnithSmoke` live run was not started. Per plan scope, a preflight failure consumes no live authorization, so the one authorized live invocation remains available for a clean run on the actual dev runner. No live provider requests were issued, no artifacts were written to `/tmp/iop-repeat-guard-live/repeat-guard-G08-12`, and no observation bytes were appended. The exact login-shell live command is preserved verbatim above and was not run.

### Summary and Cleanup Verification

Expected: `summary.json` proves the required identity/lifecycle/capacity cardinality; both providers are idle, no harness remains, runtime/source identity is unchanged, and all raw artifacts remain outside the repository.

Implementation evidence:

NOT APPLICABLE — no live run occurred. Because the single authorized live invocation was not started (see above), no `/tmp/iop-repeat-guard-live/repeat-guard-G08-12/summary.json` was produced and there is no post-run harness state to clean up. The reviewed deployed runtime was never reachable from this sandbox and remains untouched. No raw prompt/SSE/output/credential/token was generated or written to any tracked evidence path; the reviewed source identity is unchanged (test file hash `8f0c767d6fb69175c6856fcd58f1398e89b9e13c6597dc950672b14b4013bd21`, HEAD `d1e32b6e06f7153a4db5a5a08b7026d6dd49fcfb`).

---

> **[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) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| 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: Pass
  - Completeness: Fail
  - Test coverage: Fail
  - API contract: Pass
  - Code quality: Pass
  - Implementation deviation: Pass
  - Verification trust: Pass
  - Spec conformance: Fail
- Findings:
  - Required — `agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/CODE_REVIEW-cloud-G08.md:233`: the required external S07 invocation was not executed, so there are no 15 provider responses, 15 Edge correlations, three accepted capacity rows, or sanitized `reproduced`/`not_reproduced` summary. Execute the exact login-shell preflight and the single authorized live command on `/Users/toki/agent-work/iop-dev`, then record the successful sanitized summary and cleanup evidence.
- Routing Signals:
  - `review_rework_count=12`
  - `evidence_integrity_failure=false`
- Next Step: Archive this pair and invoke the plan skill for a freshly routed follow-up that executes the authorized live run on the actual dev runner.
