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

# Code Review Reference - REVIEW_OFR-REPEAT-3

> **[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=3, tag=REVIEW_OFR-REPEAT-3

## 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.
- Earlier failed loops: `plan_cloud_G10_0.log` / `code_review_cloud_G10_0.log` and `plan_cloud_G10_1.log` / `code_review_cloud_G10_1.log`.
- Immediate prior pair: `plan_cloud_G10_2.log` and `code_review_cloud_G10_2.log`; verdict FAIL.
- Required follow-up:
  - align a fatal filter's committed error terminal with its raw-free `terminal_committed` observation and permanent regression;
  - record the required clean same-ref `ornith:35b` 5-concurrent × 3 live evidence with three accepted capacity rows.

## 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-G10.md` → `code_review_cloud_G10_3.log` and `PLAN-cloud-G10.md` → `plan_cloud_G10_3.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-3-1 — Fatal terminal observation fidelity | [x] |
| REVIEW_OFR-REPEAT-3-2 — Clean same-ref live lifecycle and capacity evidence | [ ] |

## Implementation Checklist

- [x] [REVIEW_OFR-REPEAT-3-1] Make the fatal terminal sink and `terminal_committed` observation report the same error outcome and bounded causes.
- [ ] [REVIEW_OFR-REPEAT-3-2] Complete the clean same-ref `ornith:35b` capacity+1 live evidence and record sanitized identities/results.
- [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.

- [ ] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure` to `Code Review Result`.
- [ ] Verify that verdict, `Dimension Assessment`, and Required/Suggested/Nit classifications match.
- [ ] Archive active `CODE_REVIEW-*-G??.md` to `code_review_cloud_G10_3.log`.
- [ ] Archive active `PLAN-*-G??.md` to `plan_cloud_G10_3.log`.
- [ ] 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.
- [ ] If WARN/FAIL, write the next filesystem state matching code-review verdict and do not write `complete.log`.

## Deviations from Plan

- No code or test deviation for REVIEW_OFR-REPEAT-3-1.
- REVIEW_OFR-REPEAT-3-2 was not run because the reviewed correction exists only in the current dirty worktree. The plan requires one clean authorized ref and matching rebuilt/redeployed/restarted Edge and Node runtimes. Creating a commit, publishing a ref, or deploying without the authorized workflow is explicitly outside the implementing-agent scope.
- The live command was intentionally not run against the existing runtime because stale or mixed source/build/process identities cannot satisfy the acceptance evidence.

## Key Design Decisions

- `arbResult.FilterID()` takes precedence over a provider success base disposition when constructing both the committed terminal and the `terminal_committed` observation.
- The regression captures release-sink and observation-sink output from the same runtime execution and asserts one error terminal, exactly one terminal observation, terminal-committed state, no completed reason, and the same bounded filter/rule cause.
- Provider success/error behavior, public APIs, configuration, and contracts remain unchanged.

## Reviewer Checkpoints

- Confirm the terminal observation uses the same fatal-filter-first precedence as the terminal result committed to the release sink.
- Confirm the permanent regression asserts one error sink terminal and exactly one `terminal_committed` observation with empty completed reason and matching bounded filter/rule causes.
- Confirm provider success and provider error terminal paths remain unchanged and no public API/config/contract surface changed.
- Confirm local evidence is fresh and uncached and that no reviewer-only probe remains.
- Confirm live evidence comes from one clean reviewed ref rebuilt/redeployed/restarted across every participating Edge and Node; reject stale or mixed identities.
- Confirm the sanitized live result contains exactly 15 unique SSE-derived request correlations and three capacity rows satisfying `4/4/>=1/0/0`, with no raw prompt/output/token in tracked files or stdout.

## Verification Results

### Environment and Diff Hygiene

```bash
go version && go env GOMOD
git diff --check
```

Implementation evidence:

```text
$ go version && go env GOMOD
go version go1.26.2 linux/arm64
/config/workspace/iop-s1/go.mod

$ git diff --check
(no stdout; exit 0)
```

### Focused Core Terminal Fidelity

```bash
go test -race -count=1 ./packages/go/streamgate -run '^TestRequestRuntimeTerminalFailureFidelity/fatal_filter_overrides_success_terminal$'
```

Implementation evidence:

```text
ok  	iop/packages/go/streamgate	1.016s
```

### Repeat-Guard and Observation Regressions

```bash
go test -race -count=1 ./apps/edge/internal/openai -run 'Test(StreamGateConfiguredRepeatActionSplitLifecycle|RepeatGuardAssistantHistoryAnchorBoundaries|DevRepeatGuardObservationCorrelation|DevRepeatGuardCapacityEvidence)'
```

Implementation evidence:

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

### Package and Repository Regression

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

Implementation evidence:

```text
$ go test -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai
ok  	iop/packages/go/streamgate	0.952s
ok  	iop/packages/go/config	0.118s
ok  	iop/apps/edge/internal/openai	7.346s

$ make test
go test ./...
ok  	iop/apps/control-plane/cmd/control-plane	(cached)
ok  	iop/apps/control-plane/internal/wire	(cached)
ok  	iop/apps/edge/cmd/edge	(cached)
ok  	iop/apps/edge/internal/bootstrap	(cached)
ok  	iop/apps/edge/internal/configrefresh	(cached)
ok  	iop/apps/edge/internal/controlplane	(cached)
ok  	iop/apps/edge/internal/edgecmd	(cached)
ok  	iop/apps/edge/internal/edgevalidate	(cached)
ok  	iop/apps/edge/internal/events	(cached)
ok  	iop/apps/edge/internal/input	(cached)
ok  	iop/apps/edge/internal/input/a2a	(cached)
ok  	iop/apps/edge/internal/node	(cached)
ok  	iop/apps/edge/internal/openai	(cached)
ok  	iop/apps/edge/internal/opsconsole	(cached)
ok  	iop/apps/edge/internal/service	(cached)
ok  	iop/apps/edge/internal/transport	(cached)
ok  	iop/apps/node/cmd/node	(cached)
ok  	iop/apps/node/internal/adapters	(cached)
?   	iop/apps/node/internal/adapters/mock	[no test files]
ok  	iop/apps/node/internal/adapters/ollama	(cached)
ok  	iop/apps/node/internal/adapters/openai_compat	(cached)
ok  	iop/apps/node/internal/adapters/vllm	(cached)
ok  	iop/apps/node/internal/bootstrap	(cached)
ok  	iop/apps/node/internal/node	(cached)
ok  	iop/apps/node/internal/router	(cached)
ok  	iop/apps/node/internal/store	(cached)
ok  	iop/apps/node/internal/transport	(cached)
?   	iop/apps/worker/cmd/worker	[no test files]
ok  	iop/cmd/iop-provider-smoke	(cached)
ok  	iop/packages/go/agentconfig	(cached)
ok  	iop/packages/go/agentguard	(cached)
ok  	iop/packages/go/agentprovider/catalog	(cached)
ok  	iop/packages/go/agentprovider/cli	(cached)
?   	iop/packages/go/agentprovider/cli/internal/testutil	[no test files]
ok  	iop/packages/go/agentprovider/cli/status	(cached)
ok  	iop/packages/go/agentruntime	(cached)
ok  	iop/packages/go/agenttask	(cached)
ok  	iop/packages/go/audit	(cached)
?   	iop/packages/go/auth	[no test files]
ok  	iop/packages/go/config	(cached)
?   	iop/packages/go/events	[no test files]
ok  	iop/packages/go/hostsetup	(cached)
?   	iop/packages/go/jobs	[no test files]
?   	iop/packages/go/metadata	[no test files]
ok  	iop/packages/go/observability	(cached)
?   	iop/packages/go/policy	[no test files]
ok  	iop/packages/go/streamgate	(cached)
?   	iop/packages/go/version	[no test files]
?   	iop/proto/gen/iop	[no test files]
ok  	iop/scripts/inventory-query	(cached)
```

### Clean Same-Ref Dev Identity and Live Evidence

Record the clean source ref, Edge and Node build identities/checksums, running process start times, ports, selected provider IDs, and the exact live command. Then record only the sanitized 15-attempt and three-capacity-row result. If authorization is unavailable, record the exact blocker and resume condition and leave REVIEW_OFR-REPEAT-3-2 unchecked.

Implementation evidence:

```text
$ git rev-parse --abbrev-ref HEAD
feature/openai-compatible-output-validation-filters

$ git rev-parse HEAD
f4604919c0464c8b811cc9eb29203b4f9180bf6c

$ git status --short
 M agent-contract/inner/edge-config-runtime-refresh.md
 M agent-contract/outer/openai-compatible-api.md
 M agent-spec/input/openai-compatible-surface.md
 M agent-spec/runtime/provider-pool-config-refresh.md
 M agent-spec/runtime/stream-evidence-gate.md
 D agent-task/m-openai-compatible-output-validation-filters/01_resume_notice_builder/CODE_REVIEW-cloud-G08.md
 D agent-task/m-openai-compatible-output-validation-filters/01_resume_notice_builder/PLAN-cloud-G08.md
 M agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/CODE_REVIEW-cloud-G10.md
 M agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/PLAN-cloud-G10.md
 M apps/edge/internal/openai/chat_decode.go
 M apps/edge/internal/openai/openai_request_rebuilder.go
 M apps/edge/internal/openai/openai_request_rebuilder_test.go
 M apps/edge/internal/openai/responses_decode.go
 M apps/edge/internal/openai/responses_handler.go
 M apps/edge/internal/openai/responses_stream_gate.go
 M apps/edge/internal/openai/responses_types.go
 M apps/edge/internal/openai/stream_gate_filters.go
 M apps/edge/internal/openai/stream_gate_filters_test.go
 M apps/edge/internal/openai/stream_gate_pipeline_test.go
 M apps/edge/internal/openai/stream_gate_policy.go
 M apps/edge/internal/openai/stream_gate_policy_test.go
 M apps/edge/internal/openai/stream_gate_runtime.go
 M apps/edge/internal/openai/stream_gate_vertical_slice_test.go
 M configs/edge.yaml
 M packages/go/streamgate/runtime.go
 M packages/go/streamgate/runtime_test.go
?? agent-task/archive/2026/07/m-openai-compatible-output-validation-filters/01_resume_notice_builder/
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_0.log
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_1.log
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_2.log
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_0.log
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_1.log
?? agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_2.log
?? agent-task/m-openai-compatible-output-validation-filters/WORK_LOG.md
```

Status: NOT RUN.

Blocker: the terminal-observation correction is not contained in a clean, remotely addressable reviewed ref. No authorization was provided to commit, push, deploy, or restart the shared dev Edge/Node runtimes, so source/build/process identity cannot be made consistent for the required live run.

Resume condition: an authorized workflow must publish the exact reviewed work as one clean ref, clean-sync `/Users/toki/agent-work/iop-dev` to that ref, rebuild/redeploy/restart the Edge and every participating Node, record matching source commit, binary checksums/version/help, process start times, ports, and provider identities, then execute the plan's exact 5-concurrent × 3 `ornith:35b` command and record only the sanitized 15-correlation and three capacity rows.

---

> **[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: Fail
  - Verification trust: Pass
  - Spec conformance: Fail
- Findings:
  - Required — `agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/CODE_REVIEW-cloud-G10.md:61`: REVIEW_OFR-REPEAT-3-2 remains unchecked and the required clean same-ref `ornith:35b` capacity+1 live verification is explicitly `NOT RUN`. The approved SDD S07 Evidence Map and the `repeat-guard` task require one reviewed source/build/deploy/restart identity, 15 unique SSE-derived correlations, and three capacity rows satisfying `configured_capacity=4`, `peak_in_flight=4`, `peak_queued>=1`, `final_in_flight=0`, and `final_queued=0`; local fixtures cannot replace that evidence. Publish the exact reviewed work through an authorized clean-ref workflow, clean-sync and rebuild/redeploy/restart every participating Edge and Node from that ref, run the fixed 5-concurrent × 3 command, and record only the sanitized identities, 15 correlations, and three accepted capacity rows.
- Routing Signals: `review_rework_count=4`, `evidence_integrity_failure=false`
- Next Step: Archive this failed pair and create the routed follow-up PLAN/CODE_REVIEW pair for the same task path.
