<!-- task=m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence plan=2 tag=OFR-S07-SNAPSHOT-FOREGROUND-2 -->

# Code Review Reference - OFR-S07-SNAPSHOT-FOREGROUND-2

> **[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=2, tag=OFR-S07-SNAPSHOT-FOREGROUND-2

## Roadmap Targets

- Milestone: `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/openai-compatible-output-validation-filters.md`
- Task ids:
  - `repeat-guard`
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- `plan_cloud_G08_0.log` / `code_review_cloud_G08_0.log`: authentication blocker, no invocation.
- `plan_cloud_G08_1.log` / `code_review_cloud_G08_1.log`: one consumed incomplete invocation.
- `user_review_1.log`: resolved replan decision, cancelled-at-user-request cleanup, readiness tests, and zero-provider live status evidence.
- Preserve the plan-1 and direct-2 remote artifact directories. Neither is accepted S07 evidence.

## 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_2.log` and `PLAN-cloud-G09.md` → `plan_cloud_G09_2.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, report only the `repeat-guard` completion event for runtime. Do not report `ops-evidence`.
5. Check applicable `Review-Only Checklist` items at the final `.log` location before reporting.

---

## Implementation Item Completion

| Item | Status |
|------|--------|
| OFR-S07-SNAPSHOT-FOREGROUND-2-1 | [ ] |
| OFR-S07-SNAPSHOT-FOREGROUND-2-2 | [ ] |

## Implementation Checklist

- [ ] [OFR-S07-SNAPSHOT-FOREGROUND-2-1] Revalidate the clean source/auth/config/runtime baseline, perform exactly one no-change Edge config apply, and require four connected nodes plus OneXPlayer/RTX5090 provider snapshots healthy and idle at capacities `3+1`.
- [ ] [OFR-S07-SNAPSHOT-FOREGROUND-2-2] Only after the complete gate passes, start exactly one caller-owned foreground 5-concurrent × 3-run S07 invocation, validate the raw-free summary and idle cleanup, and preserve all prior artifacts.
- [x] Fill every implementation-owned section in this file with actual sanitized output, exit status, invocation count, and deviations.

## 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-cloud-G09.md` to `code_review_cloud_G09_2.log`.
- [x] Archive active `PLAN-cloud-G09.md` to `plan_cloud_G09_2.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 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, report the `repeat-guard` completion event for runtime without modifying roadmap state.
- [ ] If PASS for split work, remove an empty active parent or verify it remains for active siblings/files.
- [x] If WARN/FAIL, write the next filesystem state matching the verdict and do not write `complete.log`.

## Deviations from Plan

- The prescribed runtime snapshot command was executed without modification. Its blocked-reporting branch removed the final temporary status file and cleared `status_file` on every unsuccessful poll, including the fifteenth poll. The subsequent `jq "$status_file"` therefore failed with exit 2 instead of emitting the intended sanitized counts and exit 43.
- A supplemental read-only status query was run after that failure to capture only node/provider counts and preservation state. It did not repeat the dry-run or apply, create an artifact, access a model, or change runtime state.
- No foreground S07 invocation or summary validation was attempted because the provider snapshot gate did not pass. The exact totals remain `refresh_apply_count=1` and `invocation_count=0`.

## Key Design Decisions

- Follow the PLAN's fail-closed boundary: a no-change apply that does not restore provider snapshots cannot be escalated to a restart, rebuild, redeploy, config edit, device recovery, or model invocation.
- Treat the command's blocker-reporting defect as an evidence-capture deviation only. Preserve the actual runtime outcome and use a non-mutating query rather than rerunning the one-shot apply.
- Preserve both prior artifact directories and leave the fresh plan-2 artifact path absent.

## Reviewer Checkpoints

- Verify dry-run and apply both report `status=applied`, `changes=0`, no error, and apply count exactly one.
- Verify the apply path did not push node config, restart processes, edit config, rebuild/redeploy, recover devices, or alter source.
- Verify live status contains both provider snapshots with capacities `3+1`, healthy/idle counters, and four connected nodes before any model call.
- Verify a missing snapshot stops with `invocation_count=0`.
- Verify the live Go process, if started, stayed in the caller-owned foreground session until terminal exit and was never retried.
- Verify the accepted summary cardinalities, capacity rows, result classification, idle cleanup, source identity, artifact isolation, and secret hygiene.
- Verify PASS reports only `repeat-guard`, not `ops-evidence`.

## Verification Results

### Runtime snapshot recovery gate

Command: the complete remote command in PLAN item `OFR-S07-SNAPSHOT-FOREGROUND-2-1`.

Sanitized stdout/stderr:

```text
ok  	iop/apps/edge/internal/service	6.272s
ok  	iop/apps/edge/internal/controlplane	5.320s
ok  	iop/apps/control-plane/cmd/control-plane	1.420s
Connection to 127.0.0.1 port 18001 [tcp/*] succeeded!
Connection to 127.0.0.1 port 18083 [tcp/*] succeeded!
Connection to 127.0.0.1 port 18084 [tcp/*] succeeded!
Connection to 127.0.0.1 port 19093 [tcp/*] succeeded!
jq: error: Could not open file : No such file or directory
```

Exit status: `2`.

Control-flow evidence before the reporting defect:

- Source branch, pinned HEAD, clean remote worktree, pinned test identity, and `git diff --check`: PASS.
- Fresh artifact absence, both prior artifact directories, and harness absence: PASS.
- Protected SOPS file/key checks, token decryption, and authenticated `/v1/models` HTTP 200: PASS. No credential material was printed.
- Fresh focused package tests: PASS, as shown above.
- Edge config check, listener checks, and deployed/build executable identity: PASS.
- Dry-run: `status=applied`, `changes=0`, `error=none`.
- Apply: `status=applied`, `changes=0`, `error=none`, `refresh_apply_count=1`.
- None of the 15 status polls satisfied the required OneXPlayer/RTX5090 provider snapshot contract.

Supplemental read-only evidence command:

```bash
ssh -o BatchMode=yes -o ConnectTimeout=15 toki@toki-labs.com '/bin/zsh -lc "exec /bin/zsh -s"' <<'REMOTE'
set -euo pipefail
set +x
cd /Users/toki/agent-work/iop-dev
status_file=$(/usr/bin/mktemp -t iop-repeat-blocked.XXXXXX)
trap '/bin/rm -f "$status_file"' EXIT
/usr/bin/curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status > "$status_file"
/usr/bin/jq -r '
  "runtime_snapshot_postcheck" +
  " node_count=" + (((.nodes // []) | length) | tostring) +
  " connected_count=" + (([.nodes[]? | select(.connected == true)] | length) | tostring) +
  " provider_snapshot_count=" + (([.nodes[]?.provider_snapshots[]?] | length) | tostring) +
  " onexplayer_present=" + (([.nodes[]?.provider_snapshots[]? | select(.id == "onexplayer-lemonade")] | length) | tostring) +
  " rtx5090_present=" + (([.nodes[]?.provider_snapshots[]? | select(.id == "rtx5090-lemonade")] | length) | tostring)
' "$status_file"
test "$(git rev-parse HEAD)" = 750cb1d1cb88066a10d3c703c99f1326306d8e15
test -z "$(git status --porcelain)"
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-2
test -d /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-1
test -d /tmp/iop-repeat-guard-live/repeat-guard-task-03-direct-2
! /usr/bin/pgrep -fl '[T]estDevRepeatGuardOrnithSmoke' >/dev/null
print -r -- 'runtime_snapshot_gate=BLOCKED source=unchanged fresh_artifact=absent prior_artifacts=preserved harness=absent invocation_count=0'
REMOTE
```

Sanitized stdout:

```text
runtime_snapshot_postcheck node_count=4 connected_count=4 provider_snapshot_count=0 onexplayer_present=0 rtx5090_present=0
runtime_snapshot_gate=BLOCKED source=unchanged fresh_artifact=absent prior_artifacts=preserved harness=absent invocation_count=0
```

Supplemental exit status: `0`.

Result: `runtime_snapshot_gate=BLOCKED`, `refresh_apply_count=1`, `invocation_count=0`.

Resume condition: create a new officially reviewed PLAN with a fresh artifact path and new one-shot authorization only after the live Control Plane status exposes both `onexplayer-lemonade` and `rtx5090-lemonade` snapshots as healthy and idle at capacities `3+1`. This PLAN must not be retried.

### Foreground S07 invocation

Command: the foreground remote command in PLAN item `OFR-S07-SNAPSHOT-FOREGROUND-2-2`.

Not run. The runtime snapshot preflight remained blocked with four connected nodes but zero provider snapshots. The Go process did not start, there was no foreground process ownership to release, and there is no terminal Go test output or exit status.

`invocation_count=0`.

### Sanitized summary and cleanup

Command: the summary/cleanup command in PLAN item `OFR-S07-SNAPSHOT-FOREGROUND-2-2`.

Not run because the foreground S07 process was not permitted to start and no plan-2 artifact or `summary.json` exists.

The supplemental read-only evidence above proves:

```text
result_class=not_available provider_responses=0 edge_correlations=0 capacity_runs=0
fresh_artifact=absent prior_artifacts=preserved harness=absent source=unchanged invocation_count=0
```

Provider idle counters could not be established because the live status omitted all provider snapshots. This is the blocking contract failure, not accepted S07 cleanup evidence.

### Workspace and secret hygiene

```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'
```

Sanitized results:

```text
git diff --check: no output; exit 0
git status --short: exit 0
git grep: exit 0 because the repository contains pre-existing contract placeholders and test-only secret/redaction fixtures
```

`git status --short` showed the same pre-existing user-directed workspace changes observed before this packet:

```text
 M --check
 M agent-ops/skills/common/code-review/templates/user-review-template.md
 M agent-ops/skills/project/orchestrate-agent-task-loop/scripts/dispatch.py
 M agent-ops/skills/project/orchestrate-agent-task-loop/tests/test_dispatch.py
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/CODE_REVIEW-cloud-G10.md
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/PLAN-cloud-G10.md
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_0.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_1.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_2.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_3.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_4.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_5.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_6.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/code_review_cloud_G10_7.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_0.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_1.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_2.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_3.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_4.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_5.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_6.log
 D agent-task/m-openai-compatible-output-validation-filters/02+01_repeat_guard/plan_cloud_G10_7.log
 M agent-task/m-openai-compatible-output-validation-filters/WORK_LOG.md
 M apps/edge/internal/openai/stream_gate_vertical_slice_test.go
?? agent-task/archive/2026/07/m-openai-compatible-output-validation-filters/02+01_repeat_guard/
?? agent-task/archive/2026/07/m-openai-compatible-output-validation-filters/work_log_1.log
?? agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/
```

The task-03 directory was already untracked at baseline. This packet changed only `CODE_REVIEW-cloud-G09.md` inside it. The repository-wide grep matches were confined to pre-existing contract examples, test fixtures, and unrelated temporary/archive material; no match was reported from the active task-03 PLAN/CODE_REVIEW pair other than the literal grep pattern shown in this section. No raw token, token hash, prompt, response, SSE body, status payload, or summary was added.

---

> **[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 |
| Roadmap Targets | Fixed at stub creation from plan | Code review copies this into `complete.log` only on PASS |
| Archive Evidence Snapshot | Fixed at stub creation from plan | Read only the exact evidence cited 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 output only; command changes require a deviation |
| Code Review Result | Review agent appends | Not included in stub |

## Code Review Result

- Overall Verdict: FAIL
- Dimension Assessment:
  - Correctness: Fail — the required live provider-snapshot gate remained false after the single authorized no-change apply, so the S07 execution path never ran.
  - Completeness: Fail — both implementation items remain incomplete; there is no foreground invocation, sanitized summary, or idle-cleanup evidence.
  - Test Coverage: Fail — the focused Edge and Control Plane packages passed, but the required 5-concurrent by 3-run S07 runtime verification produced no responses, correlations, capacity rows, or terminal result.
  - API Contract: Fail — the running dev Control Plane omits `provider_snapshots` even though the active Control Plane-Edge contract and current source require that field; fresh reviewer probes show both provider hosts ready while the deployed Control Plane container lacks the current `provider_snapshots` binary contract.
  - Code Quality: Pass — this packet made no production-source change, preserved prior artifacts, and introduced no raw credential or response material.
  - Implementation Deviation: Fail — the prescribed blocked-reporting branch cleared the final `status_file`, causing exit 2 instead of the planned sanitized blocker output and exit 43; the supplemental read-only query recovered the counts but did not satisfy the planned command contract.
  - Verification Trust: Pass — the implementation reported the command defect and zero-invocation outcome accurately, and fresh read-only reviewer probes independently reproduced four connected nodes with zero provider snapshots while both Windows provider stacks reported ready.
  - Spec Conformance: Fail — SDD S07 and the targeted `repeat-guard` evidence require the full capacity+1 three-run smoke and a sanitized repeat fingerprint/offset or `not_reproduced`; none exists.
- Findings:
  - Required — `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G09.md:57`: the provider-snapshot prerequisite failed and item 2 was not run, leaving every S07 runtime acceptance cardinality absent. Rebuild and recreate the stale dev Control Plane service from the pinned clean source, prove the current `provider_snapshots` contract and healthy/idle `3+1` status, then use a fresh artifact path for exactly one attached foreground invocation and validate the complete sanitized summary and cleanup.
  - Required — `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/PLAN-cloud-G09.md:234`: every unsuccessful poll deletes the status file, including the final poll, so the blocked branch cannot emit its promised sanitized counts or exit 43. Keep the final snapshot or take one fresh read-only snapshot before blocker reporting in the follow-up verification command.
- Routing Signals:
  - `review_rework_count=3`
  - `evidence_integrity_failure=false`
- Next Step: Archive the current pair and create a freshly routed follow-up pair that replaces the stale Control Plane deployment, proves the provider snapshot contract, and permits one new isolated foreground S07 invocation only after that gate passes.
