<!-- task=m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence plan=9 tag=REVIEW_OFR-S07-CHANNEL-EVIDENCE-9 -->

# Code Review Reference - REVIEW_OFR-S07-CHANNEL-EVIDENCE-9

> **[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-30
task=m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence, plan=9, tag=REVIEW_OFR-S07-CHANNEL-EVIDENCE-9

## 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

- `plan_cloud_G09_8.log` / `code_review_cloud_G09_8.log`: FAIL with two Required findings and trusted evidence.
- Fresh uncached focused and full local profiles pass. The ordered provider identity list and bounded 25-minute deadline implementation remain accepted.
- The sole plan-8 invocation exited during run 1 with `released repeated downstream content`; no accepted `summary.json` exists, and the partial artifact remains preserved.
- A reviewer-owned read-only audit found five SSE files. Each file was non-repeating when content and reasoning were evaluated separately; four were repeating only after `devRepeatGuardSmokeText` concatenated reasoning before content. No reasoning alias appeared twice in one event.
- Remote checkout `750cb1d1cb88066a10d3c703c99f1326306d8e15` is clean. Edge PID `20646` serves the unchanged deployed plan-7 candidate, listens on five Edge ports, has four connected nodes and idle healthy `3+1` capacity, and the Control Plane status surface remains available on `18001`.
- Fresh plan-9 source/campaign-root paths are absent and no live harness is running. Preserve every plan-9 attempt independently together with plan-8 and all earlier artifacts.

## 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_9.log` and `PLAN-cloud-G08.md` → `plan_cloud_G08_9.log`.
3. If PASS, write `complete.log` and move active task directory to `agent-task/archive/YYYY/MM/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/`. 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-S07-CHANNEL-EVIDENCE-9-1 | [x] |
| REVIEW_OFR-S07-CHANNEL-EVIDENCE-9-2 | [ ] |

## Implementation Checklist

- [x] [REVIEW_OFR-S07-CHANNEL-EVIDENCE-9-1] Replace the flattened downstream text probe with content/reasoning channel-aware evidence that mirrors production reasoning alias precedence, and add deterministic cross-channel nonrepeat plus same-channel content/reasoning repeat fixtures; run fresh local profiles.
- [ ] [REVIEW_OFR-S07-CHANNEL-EVIDENCE-9-2] Build and test a fresh isolated plan-9 source overlay, prove the deployed candidate and idle `3+1` runtime remain unchanged, run a classified foreground 5-concurrent x 3-run S07 campaign of at most three immutable attempts, and validate one accepted sanitized summary plus cleanup evidence.
- [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_9.log`.
- [x] Archive active `PLAN-*-G??.md` to `plan_cloud_G08_9.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/03_repeat_guard_s07_remote_evidence/` to `agent-task/archive/YYYY/MM/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/` 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 implementation agent left every implementation-owned evidence field blank. The reviewer repaired the artifact from fresh local tests, the immutable remote overlay, and read-only remote audits so that the implementation is judgeable.
- Foreground attempt 1 created all 15 raw SSE artifacts and a structurally valid sanitized `summary.json`, then the harness disappeared without creating the success-only `accepted-attempt` marker. No terminal stdout/stderr or exit code was preserved in the active review.
- The reviewer did not create the missing marker, did not start attempt 2, and did not mutate the remote checkout, runtime, configuration, credentials, providers, prior artifacts, or roadmap.
- Reviewer verification mutations are limited to this review artifact. Model invocation count remains `1`; Edge restart count remains `0`.

## Key Design Decisions

- Downstream repetition is evaluated independently for content and canonical reasoning. Identical suffixes in different channels are not a repeat.
- `reasoning_content` takes precedence over `reasoning` within one choice, matching `decodeChatTunnelFrame`; aliases are never concatenated.
- A valid summary is not promoted to an accepted attempt without the foreground command's success marker and terminal exit evidence.

## Reviewer Checkpoints

- Verify downstream repetition is evaluated independently for content and canonical reasoning, never across their boundary.
- Verify `reasoning_content` takes precedence over `reasoning` for one choice, matching `decodeChatTunnelFrame`.
- Verify deterministic fixtures reject same-channel content and reasoning repetition but accept the cross-channel false-positive shape found in plan 8.
- Verify provider identity lists, logical terminal grammar, global uniqueness, terminal cardinality, observation correlation, and capacity checks remain unchanged.
- Verify local and isolated-remote profiles run uncached against the three-file overlay.
- Verify the remote checkout remains clean, the deployed candidate hash and PID remain unchanged, no restart occurs, and plan-9 paths were fresh before use.
- Verify exact five Edge listeners, four connected nodes, idle healthy `3+1` capacity, and protected `/v1/models` HTTP 200 before every consumed attempt.
- Verify only one S07 process runs at a time; attempts use immutable paths; preflight exits consume no ordinal; and only classified transient failures may retry while source/overlay/runtime identity and cleanup remain valid.
- Verify the campaign stops on a non-retryable failure, repeated normalized transient failure, cleanup/identity drift, three consumed attempts, or the 210-minute budget gate, and that no review occurs between authorized transient attempts.
- Verify exactly one accepted attempt supplies summary/cleanup evidence and prior failed attempts remain preserved without synthesized or merged evidence.
- Verify PASS reports only `repeat-guard`, not `ops-evidence`.

## Verification Results

### Channel-aware downstream evidence and local profile

Commands:

```bash
go version
go env GOMOD
go test -count=1 ./apps/edge/internal/openai -run '^(TestStreamGateChatTunnelRepeatRecoveryExhaustionTerminatesSSE|TestDevRepeatGuardDownstreamRepeatEvidence|TestDevRepeatGuardRequestDeadline|TestDevRepeatGuardSmokeEvidence|TestDevRepeatGuardObservationCorrelation|TestDevRepeatGuardCapacityEvidence)$'
go test -count=1 ./packages/go/streamgate ./apps/edge/internal/openai
git diff --check
```

Implementation evidence:

Reviewer rerun; every command exited `0`:

```text
go version go1.26.2 linux/arm64
/config/workspace/iop-s1/go.mod
ok  	iop/apps/edge/internal/openai	0.329s
ok  	iop/packages/go/streamgate	0.877s
ok  	iop/apps/edge/internal/openai	7.329s
```

`git diff --check` produced no output. `TestDevRepeatGuardDownstreamRepeatEvidence` passed the cross-channel nonrepeat, same-channel content repeat, same-channel reasoning repeat, `reasoning_content` precedence, and single-event alias non-concatenation fixtures.

### Isolated remote plan-9 overlay

Commands:

- Execute the exact overlay and isolated profile commands in `PLAN-cloud-G08.md`.

Implementation evidence:

Reviewer-verified immutable manifest:

```text
207698668e0c51994a2e286357d0f97ebb94b8e6cf7f221b611a02deb54c9175  apps/edge/internal/openai/stream_gate_release_sink.go
24fc8f20ffb8c23e5aef44d2ccfce48adef65a5aad2bef1eb2d01bb6b9e642a0  apps/edge/internal/openai/stream_gate_tunnel_codec.go
376b3bf47603f6050afea0f5515b49a5e75bcae59108ee9d20d2a893f642c421  apps/edge/internal/openai/stream_gate_vertical_slice_test.go
```

Fresh reviewer rerun exited `0`:

```text
apps/edge/internal/openai/stream_gate_release_sink.go: OK
apps/edge/internal/openai/stream_gate_tunnel_codec.go: OK
apps/edge/internal/openai/stream_gate_vertical_slice_test.go: OK
go version go1.26.3 darwin/arm64
ok  	iop/packages/go/streamgate	1.263s
ok  	iop/apps/edge/internal/openai	7.829s
review_remote_overlay=PASS base_head=750cb1d1cb88066a10d3c703c99f1326306d8e15 runtime_hash=e0eff854e5c6841e6dd5cafcd7242254c91ece26b4ad328a2b937acca42122e5 edge_pid=20646 edge_listeners=5 edge_restart_count=0
```

The remote checkout was clean and the deployed binary continued to match the preserved plan-7 candidate.

### Bounded foreground S07 campaign

Commands:

- Execute the parameterized `remote_live_start` command in `PLAN-cloud-G08.md` for attempt 1 and only the authorized next unused ordinal after a classified transient failure. Never exceed three consumed attempts.

Implementation evidence:

Reviewer-observed raw-free ledger:

```text
attempt=1 artifact=plan-9/attempt-1 source_manifest=verified base_head=750cb1d1cb88066a10d3c703c99f1326306d8e15 runtime_hash=e0eff854e5c6841e6dd5cafcd7242254c91ece26b4ad328a2b937acca42122e5 edge_pid=20646 edge_listeners=5 invocation_count=1 raw_sse_files=15 summary_present=true harness=absent terminal_exit=unavailable failure_class=unproven accepted_marker=absent decision=stop
```

The reviewer independently confirmed four connected nodes, healthy idle `3+1` capacity, protected `/v1/models` HTTP `200`, the unchanged runtime candidate, and a clean checkout. Because the implementation preserved neither `remote_live_finish=PASS` nor a terminal exit code and did not create `accepted-attempt`, the reviewer did not classify a transient failure or authorize another attempt.

### Sanitized summary and cleanup

Commands:

- Execute the exact summary/cleanup command in `PLAN-cloud-G08.md` only after a successful foreground run.

Implementation evidence:

The preserved summary passed the structural validator but is not accepted because the success marker is absent:

```text
review_summary_audit=PASS result=reproduced logical_provider_responses=15 edge_correlations=15 capacity_runs=3 providers=idle harness=absent candidate=unchanged checkout=clean prior_artifacts=preserved accepted_marker=no
review_reproduction_evidence fingerprint=9474434e3c6cbe6cfdc21c8acf90188afe51c68231d4a76c02f85c900169e7f3 offset=508
```

All three capacity rows report configured capacity `4`, peak in-flight `4`, queue pressure, and final idle state. Attempt 1 and every prior artifact remain preserved; no summary or marker was synthesized or merged.

### Workspace hygiene

Commands:

```bash
git diff --check
git status --short
git grep -nE 'sk-[A-Za-z0-9_-]{16,}|Authorization: Bearer [^$]' -- . \
  ':(exclude)agent-task/archive/**' \
  ':(exclude)agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/*.log'
```

Implementation evidence:

`git diff --check` exited `0` with no output. `git status --short` showed the scoped source/test changes and task artifacts alongside unrelated pre-existing user/task changes.

The path-only secret-like pattern scan found only pre-existing contract, roadmap, test, documentation, dispatcher, and ignored temporary-plan paths. Neither the scoped source file nor this active review file appeared. No matching content was printed.

## Code Review Result

- Overall Verdict: FAIL
- Dimension Assessment:
  - Correctness: Pass — the channel-aware parser, production alias precedence, and deterministic fixtures are correct, and the preserved summary passes its structural invariants.
  - Completeness: Fail — `REVIEW_OFR-S07-CHANNEL-EVIDENCE-9-2` has no accepted foreground attempt because the required success marker and terminal exit evidence are absent.
  - Test Coverage: Fail — local and isolated-remote suites pass, but the required integrated S07 command has no trusted terminal result.
  - API Contract: Pass — content and reasoning provenance now match the production tunnel codec and approved Stream Evidence Gate contract.
  - Code Quality: Pass.
  - Implementation Deviation: Fail — the active review was left blank and attempt 1 stopped without the success-only acceptance marker; the required accepted-summary cleanup path was not completed.
  - Verification Trust: Fail — fresh reviewer evidence validates the summary contents and current cleanup state but cannot reconstruct or assume the foreground command's exit code.
  - Spec Conformance: Fail — SDD S07 and its Evidence Map require accepted capacity+1 evidence; a markerless summary is insufficient.
- Findings:
  - Required — `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G08.md:176`: foreground attempt 1 left 15 SSE files and a structurally valid `reproduced` summary but no `accepted-attempt`, `remote_live_finish=PASS`, or terminal exit code. Preserve attempt 1, do not synthesize its marker, and prepare the smallest evidence-recovery follow-up that obtains a durable classified terminal result and one accepted immutable attempt before claiming S07 completion.
- Routing Signals:
  - `review_rework_count=10`
  - `evidence_integrity_failure=true`
- Next Step: Prepare the smallest fresh follow-up plan for durable foreground terminal evidence and one accepted immutable S07 attempt; do not write `complete.log`.
- Finalization Status: Completed. The prepared follow-up PLAN passed the permitted `dispatch.py --validate-plan` check, the verdict pair was archived as suffix `9`, and the routed plan-10 `cloud-G08` pair was materialized without writing `complete.log`.
- Resume Condition: Execute the active plan-10 durable foreground evidence recovery, fill its implementation-owned review fields, and return it for official review.

---

> **[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 |
