<!-- task=m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence plan=4 tag=REVIEW_OFR-S07-PINNED-CONTEXT-4 -->

# Build the Control Plane from the pinned checkout before one isolated S07 run

## For the Implementing Agent

Filling every implementation-owned section in `CODE_REVIEW-cloud-G10.md` is mandatory. Run the verification exactly once within its mutation and invocation boundaries, record actual sanitized output and exit status, keep the active PLAN/CODE_REVIEW pair in place, and report ready for official review.

If blocked, record only the exact blocker, attempted commands/output, invocation count, and resume condition in implementation-owned evidence fields. Do not ask the user, call user-input tools, create control-plane stop files, classify the next state, archive logs, write `complete.log`, or modify roadmap state.

This packet authorizes one Control Plane image build from the explicit pinned `iop-dev` checkout, one force-recreate of only that compose service, and at most one new foreground S07 invocation after every gate passes. It does not authorize an Edge restart/config apply, provider recovery, config edit, credential change, prior-artifact deletion, detached harness, or model retry.

## Background

The prior compose rebuild ran from `/Users/toki/agent-work/iop-dev`, but `context: ..` plus Dockerfile `COPY iop/` built sibling `/Users/toki/agent-work/iop` instead. The resulting container was healthy but lacked the current `provider_snapshots` contract, so the required S07 invocation did not start. The correction is to create an isolated temporary Docker context from the pinned feature checkout and the pinned `proto-socket/go` dependency, build the compose image tag from that context, prove image provenance and the live status contract, and then run one fresh S07 attempt.

## Archive Evidence Snapshot

- `plan_cloud_G08_0.log` / `code_review_cloud_G08_0.log`: authentication blocker; `invocation_count=0`.
- `plan_cloud_G08_1.log` / `code_review_cloud_G08_1.log`: one consumed incomplete invocation; no accepted summary.
- `user_review_1.log`: resolved authorization/replan boundary and zero-provider-snapshot diagnosis.
- `plan_cloud_G09_2.log` / `code_review_cloud_G09_2.log`: no-change Edge apply left provider snapshots absent; `invocation_count=0`.
- `plan_cloud_G10_3.log` / `code_review_cloud_G10_3.log`: FAIL because the compose build copied sibling `iop` at `89660dc1bd3547deb1ecb4906b13eeafc1000f60`, not pinned `iop-dev` at `750cb1d1cb88066a10d3c703c99f1326306d8e15`; the rebuilt image and live status had zero provider snapshots, and `invocation_count=0`.
- Preserve all earlier `/tmp/iop-repeat-guard-live/repeat-guard-task-03-*` artifacts. Use only the fresh plan-4 build-context, build-log, and result paths declared below.

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

## Analysis

### Files Read

- `docker-compose.yml`
- `apps/control-plane/Dockerfile`
- `apps/control-plane/cmd/control-plane/http_views.go`
- `apps/control-plane/cmd/control-plane/edge_registry_handler_test.go`
- `apps/edge/internal/controlplane/connector.go`
- `apps/edge/internal/service/status_provider.go`
- `apps/edge/internal/service/model_queue_snapshot.go`
- `agent-contract/inner/control-plane-edge-wire.md`
- `agent-contract/inner/edge-config-runtime-refresh.md`
- `agent-contract/outer/openai-compatible-api.md`
- `agent-spec/runtime/stream-evidence-gate.md`
- `agent-spec/runtime/provider-pool-config-refresh.md`
- `agent-spec/control/control-plane-operations.md`
- `agent-roadmap/phase/knowledge-tool-optimization-extension/PHASE.md`
- `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/openai-compatible-output-validation-filters.md`
- `agent-roadmap/sdd/knowledge-tool-optimization-extension/openai-compatible-output-validation-filters/SDD.md`
- `agent-test/local/rules.md`
- `agent-test/local/edge-smoke.md`
- `agent-test/local/control-plane-smoke.md`
- `agent-test/local/testing-smoke.md`
- `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/PLAN-cloud-G10.md`
- `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G10.md`

### SDD Criteria

- SDD: `agent-roadmap/sdd/knowledge-tool-optimization-extension/openai-compatible-output-validation-filters/SDD.md`; status `[승인됨]`; lock `해제`.
- Targeted scenarios: S03/S04 define deterministic `repeat-guard` continuation and safe-stop behavior. S07 requires a dev `ornith:35b`, `stream=true`, capacity+1 smoke for at least three runs and accepts either a sanitized fingerprint/offset or `not_reproduced`.
- Evidence Map: S03/S04 remain supported by the completed deterministic fixture packet. This packet closes the S07 live evidence gap with one 5-concurrent x 3-run invocation, 15 provider-response ids, 15 Edge correlation ids, three capacity rows, accepted result classification, idle cleanup, and raw-free evidence.
- PASS reports only `repeat-guard`; the broader S07 `ops-evidence` logging row is not claimed.

### Verification Context

- Handoff: current FAIL review plus fresh repository-native and remote read-only reviewer probes.
- Runner/workdir: `ssh toki@toki-labs.com`, `/Users/toki/agent-work/iop-dev`, Darwin/arm64, login zsh. Direct Windows readiness probes use the declared OneXPlayer and RTX5090 SSH targets.
- Source: feature checkout branch `feature/openai-compatible-output-validation-filters`, HEAD `750cb1d1cb88066a10d3c703c99f1326306d8e15`, clean, with `provider_snapshots` in the Control Plane source. `proto-socket` HEAD is `3c1ffe87e560852c95c7f5f5b98e9c07eae8fdde`; its `go` subtree is clean.
- Contradicted production path: compose resolved build context to `/Users/toki/agent-work`, and `apps/control-plane/Dockerfile` copied `iop/`. The actual source was sibling `/Users/toki/agent-work/iop` on `main` at `89660dc1bd3547deb1ecb4906b13eeafc1000f60`, whose Control Plane source has no provider snapshot JSON view.
- Current runtime: image/container `sha256:75587e5f94c688941059fba297141289b7661c8c7ec760f882f0fd82c6572455` is healthy/ready and reports four connected nodes but zero provider snapshots. Both provider hosts are independently ready, healthy, model-loaded, publicly listening, and Edge-connected.
- Setup: create `/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4-build-context`, populate `iop/` from `git archive` of the pinned feature HEAD, copy only the clean sibling `proto-socket/go`, attach source labels, build `iop-dev-agent-control-plane:latest` once, and recreate only the Control Plane with `--no-build`.
- Credential: decrypt token ref `toki-dev-pi` only inside `set +x` on the dev host using the declared SOPS file and age key; never print token material.
- Required commands exist: Docker client 27.4.0, Compose 2.31.0, `/usr/bin/git`, `/usr/bin/tar`, `/usr/bin/ditto`, `/usr/bin/strings`, Go, curl, jq, and SOPS.
- Ports/runtime: Control Plane HTTP 18001; native Edge OpenAI 18083, refresh 18084, and node transport 19093. The harness is absent and the plan-4 artifact/build paths are fresh.
- Constraints: exactly one image build, one Control Plane force-recreate, no other runtime mutation, and at most one caller-owned foreground model invocation. Confidence is high because the source-path mismatch and resulting binary/status contract were directly reproduced.

### Test Coverage Gaps

- Existing Control Plane and Edge tests cover provider snapshot wire mapping, HTTP serialization, and provider capacity fields.
- Unit tests cannot prove which checkout a Docker image copied. Explicit temporary-context population, image source labels, running-image identity, binary string inspection, and live HTTP status close that gap.
- Only `TestDevRepeatGuardOrnithSmoke` closes the required S07 live capacity/cardinality/cleanup gap. Synthetic or degraded-capacity evidence is not accepted.

### Symbol References

- None. No production symbol is renamed, removed, or added.

### Split Judgment

- Keep the corrected image build/recreate and S07 invocation in one packet. The single-use model invocation is valid only against the exact image/status generation proven immediately beforehand, so splitting would sever the evidence invariant.

### Scope Rationale

- The only workspace write is implementation evidence in `CODE_REVIEW-cloud-G10.md`.
- Remote writes are limited to the exact plan-4 temporary build context, one build log, the replacement Control Plane image/container, and the plan-4 harness artifacts.
- Production source, tracked config, Edge/Node/provider processes, credentials, prior artifacts, roadmap, and sibling checkouts are excluded.

### Final Routing

- `evaluation_mode=isolated-reassessment`; finalizer `finalize-task-policy.sh`, mode `pair`.
- Build closures: scope/context/verification/evidence/ownership/decision are all true. Scores `2/2/2/2/2` produce cloud G10 with base and final route basis `grade-boundary`.
- Review closures: scope/context/verification/evidence/ownership/decision are all true. Scores `2/2/2/2/2` produce cloud G10 with route basis `official-review`.
- `large_indivisible_context=false`; matched loop risks: `temporal_state`, `concurrent_consistency`, `boundary_contract`, `structured_interpretation`; count 4.
- Recovery signals: `review_rework_count=4`, `evidence_integrity_failure=true`; risk and recovery boundaries both match without replacing the grade-boundary basis.
- Canonical files: `PLAN-cloud-G10.md` and `CODE_REVIEW-cloud-G10.md`; review adapter `codex`, model `gpt-5.6-sol`, reasoning effort `xhigh`.

## Implementation Checklist

- [ ] [REVIEW_OFR-S07-PINNED-CONTEXT-4-1] Prove both providers and the pinned source/dependency state, build exactly one Control Plane image from an isolated context populated from pinned `iop-dev`, recreate only that service exactly once, and require matching source labels, the current binary contract, four connected nodes, and healthy/idle provider capacities `3+1`.
- [ ] [REVIEW_OFR-S07-PINNED-CONTEXT-4-2] Only after the complete image/status gate passes, start exactly one caller-owned foreground 5-concurrent x 3-run S07 invocation on the fresh plan-4 path, validate the raw-free summary and idle cleanup, and preserve every prior artifact.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

### [REVIEW_OFR-S07-PINNED-CONTEXT-4-1] Build and deploy the pinned Control Plane image

#### Problem

`docker-compose.yml:37` resolves the build context to the parent directory, while `apps/control-plane/Dockerfile:9` and `apps/control-plane/Dockerfile:13` copy `iop/`. From the dev worktree this selects sibling `iop`, not pinned `iop-dev`, so the prior image did not contain `apps/control-plane/cmd/control-plane/http_views.go:144`.

#### Solution

- Recheck provider readiness, pinned feature source, the clean `proto-socket/go` dependency, ports, tools, prior-artifact preservation, and fresh focused tests.
- Populate a fresh exact temporary Docker context with `git archive HEAD` under `iop/` and a copy of the clean `proto-socket/go` subtree.
- Build `iop-dev-agent-control-plane:latest` once with source labels, then run compose `up` once with `--no-build --no-deps --force-recreate`.
- Require a changed image/container identity, matching source labels, at least one `provider_snapshots` binary string, health/readiness, Edge reconnection, four connected nodes, and healthy/idle OneXPlayer/RTX5090 capacities `3+1`.
- On any failure, print a sanitized stage and stop with `invocation_count=0`. Do not repeat or escalate the mutation.

Before:

```text
compose_context=/Users/toki/agent-work docker_copy=iop source=/Users/toki/agent-work/iop provider_snapshot_contract=absent
```

After:

```text
image_source_repo=iop-dev image_source_head=750cb1d1... provider_snapshot_contract=current nodes=4 providers=3+1_idle
```

#### Modified Files and Checklist

- [ ] `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G10.md` - record direct provider readiness, source/dependency identity, focused tests, isolated-context build, image/container provenance, contract/status gate, and exact exit status.
- [ ] No production source, tracked config, Edge/Node/provider process, credential, prior artifact, sibling checkout, or roadmap change.

#### Test Strategy

Do not add tests. Existing source tests cover the status contract; this item verifies the previously untested Docker source-selection and deployed-runtime boundary directly. Fresh `-count=1` package tests are required before the single build.

#### Verification

Direct provider readiness:

```bash
ssh -o BatchMode=yes -o ConnectTimeout=15 r0bin@192.168.0.59 \
  'powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:/Users/r0bin/iop-field/remote-llm-toggle.ps1 -Action Status' |
  jq -e '.success == true and .state.ready == true and .state.health == "ok" and .state.model_loaded == true and .state.profile_valid == true and .state.listener_public == true and .state.edge_connected == true'

ssh -o BatchMode=yes -o ConnectTimeout=15 iop-dev-rtx5090 \
  'powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:/Users/r0bin/iop-field/remote-llm-toggle.ps1 -Action Status' |
  jq -e '.success == true and .state.ready == true and .state.health == "ok" and .state.model_loaded == true and .state.profile_valid == true and .state.listener_public == true and .state.edge_connected == true'
```

Expected: both commands exit 0 and perform no provider mutation.

Pinned isolated-context build/recreate and status gate:

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

expected_head=750cb1d1cb88066a10d3c703c99f1326306d8e15
expected_proto_head=3c1ffe87e560852c95c7f5f5b98e9c07eae8fdde
expected_test_hash=46261bb3a3000e00c27c419682f741c64c31c849d0aa30cbc024ed4531e7bfa6
test_file=apps/edge/internal/openai/stream_gate_vertical_slice_test.go
build_context=/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4-build-context
build_log=/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4-control-plane-build.log
artifact_dir=/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4
status_file=$(/usr/bin/mktemp -t iop-repeat-cp-status.XXXXXX)
cleanup() {
  /bin/rm -f -- "$status_file"
  /bin/rm -rf -- /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4-build-context
}
trap cleanup EXIT

test "$(git branch --show-current)" = feature/openai-compatible-output-validation-filters
test "$(git rev-parse HEAD)" = "$expected_head"
test -z "$(git status --porcelain)"
test "$(git -C /Users/toki/agent-work/proto-socket rev-parse HEAD)" = "$expected_proto_head"
test -z "$(git -C /Users/toki/agent-work/proto-socket status --porcelain -- go)"
test "$(/usr/bin/shasum -a 256 "$test_file" | /usr/bin/awk '{print $1}')" = "$expected_test_hash"
test "$(/usr/bin/grep -c 'json:\"provider_snapshots,omitempty\"' apps/control-plane/cmd/control-plane/http_views.go)" -ge 1
git diff --check
test ! -e "$build_context"
test ! -e "$build_log"
test ! -e "$artifact_dir"
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
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-2
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-3
test -f /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-3-control-plane-build.log
! /usr/bin/pgrep -fl '[T]estDevRepeatGuardOrnithSmoke' >/dev/null

docker_bin=$(command -v docker)
go_bin=$(command -v go)
test -n "$docker_bin"
test -n "$go_bin"
test "$(command -v git)" = /usr/bin/git
test "$(command -v tar)" = /usr/bin/tar
test "$(command -v ditto)" = /usr/bin/ditto
test "$(command -v strings)" = /usr/bin/strings
"$docker_bin" compose version
for port in 18001 18083 18084 19093; do /usr/bin/nc -z 127.0.0.1 "$port"; done
"$go_bin" test -count=1 ./apps/edge/internal/service ./apps/edge/internal/controlplane ./apps/control-plane/cmd/control-plane

before_container=$("$docker_bin" ps --filter publish=18001 --format '{{.ID}}' | /usr/bin/head -1)
before_image=$("$docker_bin" image inspect iop-dev-agent-control-plane:latest --format '{{.Id}}')
test -n "$before_container"
test -n "$before_image"

/bin/mkdir -p "$build_context/iop" "$build_context/proto-socket"
git archive --format=tar HEAD | /usr/bin/tar -xf - -C "$build_context/iop"
/usr/bin/ditto /Users/toki/agent-work/proto-socket/go "$build_context/proto-socket/go"
test "$(/usr/bin/shasum -a 256 "$build_context/iop/$test_file" | /usr/bin/awk '{print $1}')" = "$expected_test_hash"
test "$(/usr/bin/grep -c 'json:\"provider_snapshots,omitempty\"' "$build_context/iop/apps/control-plane/cmd/control-plane/http_views.go")" -ge 1

if ! "$docker_bin" build --no-cache \
  --label iop.source.repo=iop-dev \
  --label "iop.source.head=$expected_head" \
  --label "iop.source.proto_socket_head=$expected_proto_head" \
  --tag iop-dev-agent-control-plane:latest \
  --file "$build_context/iop/apps/control-plane/Dockerfile" \
  "$build_context" >"$build_log" 2>&1; then
  /usr/bin/tail -80 "$build_log"
  print -r -- 'control_plane_redeploy_gate=BLOCKED stage=build invocation_count=0'
  exit 61
fi

new_image=$("$docker_bin" image inspect iop-dev-agent-control-plane:latest --format '{{.Id}}')
source_repo=$("$docker_bin" image inspect iop-dev-agent-control-plane:latest --format '{{index .Config.Labels "iop.source.repo"}}')
source_head=$("$docker_bin" image inspect iop-dev-agent-control-plane:latest --format '{{index .Config.Labels "iop.source.head"}}')
proto_head=$("$docker_bin" image inspect iop-dev-agent-control-plane:latest --format '{{index .Config.Labels "iop.source.proto_socket_head"}}')
if [[ -z "$new_image" || "$new_image" = "$before_image" || "$source_repo" != iop-dev || "$source_head" != "$expected_head" || "$proto_head" != "$expected_proto_head" ]]; then
  print -r -- 'control_plane_redeploy_gate=BLOCKED stage=image_provenance invocation_count=0'
  exit 62
fi

if ! "$docker_bin" compose --env-file .env.dev.example up -d --no-deps --force-recreate --no-build control-plane >>"$build_log" 2>&1; then
  /usr/bin/tail -80 "$build_log"
  print -r -- 'control_plane_redeploy_gate=BLOCKED stage=recreate invocation_count=0'
  exit 63
fi

after_container=$("$docker_bin" ps --filter publish=18001 --format '{{.ID}}' | /usr/bin/head -1)
after_image=$("$docker_bin" inspect --format '{{.Image}}' "$after_container")
contract_hits=$("$docker_bin" exec "$after_container" sh -c "strings /usr/local/bin/control-plane | grep -c provider_snapshots || true")
if [[ -z "$after_container" || "$after_container" = "$before_container" || "$after_image" != "$new_image" || "$contract_hits" -lt 1 ]]; then
  print -r -- "control_plane_redeploy_gate=BLOCKED stage=running_contract contract_hits=$contract_hits invocation_count=0"
  exit 64
fi

ready=false
for _ in {1..30}; do
  if /usr/bin/curl -fsS http://127.0.0.1:18001/healthz >/dev/null &&
     /usr/bin/curl -fsS http://127.0.0.1:18001/readyz >/dev/null &&
     /usr/bin/curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status >"$status_file" &&
     /usr/bin/jq -e '
       def provider($id): first(.nodes[]?.provider_snapshots[]? | select(.id == $id));
       ((.error // "") == "") and
       ((.nodes // []) | length == 4) and
       (all(.nodes[]; .connected == true)) and
       (provider("onexplayer-lemonade").capacity == 3) and
       (provider("onexplayer-lemonade").health == "healthy") and
       (provider("onexplayer-lemonade").in_flight == 0) and
       (provider("onexplayer-lemonade").queued == 0) and
       (provider("rtx5090-lemonade").capacity == 1) and
       (provider("rtx5090-lemonade").health == "healthy") and
       (provider("rtx5090-lemonade").in_flight == 0) and
       (provider("rtx5090-lemonade").queued == 0)
     ' "$status_file" >/dev/null; then
    ready=true
    break
  fi
  sleep 2
done

if [[ "$ready" != true ]]; then
  /usr/bin/curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status >"$status_file" || true
  /usr/bin/jq -c '{
    error: (.error // null),
    node_count: ((.nodes // []) | length),
    connected_count: ([.nodes[]? | select(.connected == true)] | length),
    provider_snapshot_count: ([.nodes[]?.provider_snapshots[]?] | length)
  }' "$status_file" 2>/dev/null || print -r -- '{"status":"unavailable"}'
  print -r -- 'control_plane_redeploy_gate=BLOCKED stage=status invocation_count=0'
  exit 65
fi

print -r -- "control_plane_redeploy_gate=PASS image_source=iop-dev source_head=$source_head contract_hits=$contract_hits nodes=4 providers=3+1_idle build_log=$build_log invocation_count=0"
REMOTE
```

Expected: fresh tests pass; exactly one image build and one Control Plane recreate occur; the terminal line proves the pinned image, current binary contract, four connected nodes, and idle `3+1` provider capacity. Any blocked stage is non-retryable for this packet and leaves `invocation_count=0`.

### [REVIEW_OFR-S07-PINNED-CONTEXT-4-2] Run one attached S07 invocation and verify cleanup

#### Problem

The prior packet never started the mandatory SDD S07 invocation. No accepted plan-3 summary, provider-response cardinality, Edge correlation cardinality, capacity timeline, or result classification exists.

#### Solution

- Recheck pinned source, fresh plan-4 artifact absence, harness absence, protected SOPS authentication, exact running image labels, binary contract, and live `3+1` provider status immediately before launch.
- Start `TestDevRepeatGuardOrnithSmoke` once in the same foreground SSH shell. Do not detach, background, timeout-retry, or create another artifact path.
- Record the exact terminal Go output and exit status. Any exit after `remote_live_start` consumes the invocation.
- On exit 0, validate `summary.json` without printing it, require all cardinalities/capacity rows/result classification, prove both providers idle, prove the harness absent, and preserve source/prior artifacts.

#### Modified Files and Checklist

- [ ] `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G10.md` - record the single foreground invocation and sanitized summary/cleanup evidence.
- [ ] No source/config/Control Plane/Edge/Node/provider/credential/roadmap mutation after the post-redeploy gate.

#### Test Strategy

Use only the existing `TestDevRepeatGuardOrnithSmoke` five-concurrent, three-run, two-provider contract. Synthetic summaries, degraded capacity, detached processes, and retries are forbidden.

#### Verification

Foreground invocation:

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

expected_head=750cb1d1cb88066a10d3c703c99f1326306d8e15
expected_image_repo=iop-dev
artifact_dir=/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4
secret=/Users/toki/.config/iop/secrets/dev-openai-toki.sops.yaml
age_key=/Users/toki/.config/sops/age/keys.txt
status_file=$(/usr/bin/mktemp -t iop-repeat-live-status.XXXXXX)
api_key=''
cleanup() {
  /bin/rm -f -- "$status_file"
  unset api_key
}
trap cleanup EXIT

test "$(git rev-parse HEAD)" = "$expected_head"
test -z "$(git status --porcelain)"
test "$(/usr/bin/shasum -a 256 apps/edge/internal/openai/stream_gate_vertical_slice_test.go | /usr/bin/awk '{print $1}')" = 46261bb3a3000e00c27c419682f741c64c31c849d0aa30cbc024ed4531e7bfa6
test ! -e "$artifact_dir"
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
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-2
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-3
! /usr/bin/pgrep -fl '[T]estDevRepeatGuardOrnithSmoke' >/dev/null

container=$(docker ps --filter publish=18001 --format '{{.ID}}' | /usr/bin/head -1)
test -n "$container"
test "$(docker inspect --format '{{index .Config.Labels "iop.source.repo"}}' "$container")" = "$expected_image_repo"
test "$(docker inspect --format '{{index .Config.Labels "iop.source.head"}}' "$container")" = "$expected_head"
test "$(docker exec "$container" sh -c "strings /usr/local/bin/control-plane | grep -c provider_snapshots || true")" -ge 1

test -x /opt/homebrew/bin/sops
test -r "$age_key"
test -r "$secret"
test "$(/usr/bin/stat -f %Lp "$secret")" = 600
api_key=$(SOPS_AGE_KEY_FILE="$age_key" /opt/homebrew/bin/sops decrypt --extract '["tokens"]["toki-dev-pi"]' "$secret")
test -n "$api_key"

/usr/bin/curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status >"$status_file"
/usr/bin/jq -e '
  def provider($id): first(.nodes[]?.provider_snapshots[]? | select(.id == $id));
  ((.nodes // []) | length == 4) and
  (all(.nodes[]; .connected == true)) and
  (provider("onexplayer-lemonade").capacity == 3) and
  (provider("onexplayer-lemonade").health == "healthy") and
  (provider("onexplayer-lemonade").in_flight == 0) and
  (provider("onexplayer-lemonade").queued == 0) and
  (provider("rtx5090-lemonade").capacity == 1) and
  (provider("rtx5090-lemonade").health == "healthy") and
  (provider("rtx5090-lemonade").in_flight == 0) and
  (provider("rtx5090-lemonade").queued == 0)
' "$status_file" >/dev/null

http_status=$(
  {
    print -r -- 'silent'
    print -r -- 'show-error'
    print -r -- 'output = "/dev/null"'
    print -r -- "header = \"Authorization: Bearer $api_key\""
  } | /usr/bin/curl --config - --write-out '%{http_code}' http://127.0.0.1:18083/v1/models
)
test "$http_status" = 200
/bin/rm -f -- "$status_file"

print -r -- 'remote_live_start invocation_count=1 ownership=foreground artifact=plan-4'
IOP_OPENAI_API_KEY="$api_key" \
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="$artifact_dir" \
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 \
"$(command -v go)" test -timeout 90m -count=1 -v ./apps/edge/internal/openai -run '^TestDevRepeatGuardOrnithSmoke$'
REMOTE
```

Expected: the SSH session stays attached until the single Go invocation exits. Exit 0 is required; any non-zero exit after `remote_live_start` is consumed and must not be retried.

Sanitized summary and cleanup:

```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
summary=/tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-4/summary.json
status_file=$(/usr/bin/mktemp -t iop-repeat-cleanup.XXXXXX)
trap '/bin/rm -f "$status_file"' EXIT

test -f "$summary"
/usr/bin/jq -e '
  (.model == "ornith:35b") and (.concurrency == 5) and (.runs == 3) and
  ((.provider_responses | length) == 15) and
  (([.provider_responses[].provider_response_id] | unique | length) == 15) and
  ((.lifecycles | length) == 15) and
  (([.lifecycles[].correlation_id] | unique | length) == 15) and
  ((.capacity_runs | length) == 3) and
  (all(.capacity_runs[];
    (.configured_capacity == 4) and (.peak_in_flight == 4) and
    (.peak_queued >= 1) and (.final_in_flight == 0) and (.final_queued == 0))) and
  ((.result == "not_reproduced") or
    ((.result == "reproduced") and
     any(.lifecycles[];
       (.result == "reproduced") and
       ((.fingerprint // "") | length > 0) and
       (.offset >= 0))))
' "$summary" >/dev/null
result_evidence=$(/usr/bin/jq -r '
  if .result == "reproduced" then
    first(.lifecycles[] |
      select(.result == "reproduced") |
      "result=reproduced fingerprint=\(.fingerprint) offset=\(.offset)")
  else
    "result=not_reproduced"
  end
' "$summary")

/usr/bin/curl -fsS http://127.0.0.1:18001/edges/edge-toki-labs-dev/status >"$status_file"
/usr/bin/jq -e '
  def provider($id): first(.nodes[]?.provider_snapshots[]? | select(.id == $id));
  (provider("onexplayer-lemonade").in_flight == 0) and
  (provider("onexplayer-lemonade").queued == 0) and
  (provider("rtx5090-lemonade").in_flight == 0) and
  (provider("rtx5090-lemonade").queued == 0)
' "$status_file" >/dev/null
! /usr/bin/pgrep -fl '[T]estDevRepeatGuardOrnithSmoke' >/dev/null
test "$(git rev-parse HEAD)" = 750cb1d1cb88066a10d3c703c99f1326306d8e15
test -z "$(git status --porcelain)"
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
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-2
test ! -e /tmp/iop-repeat-guard-live/repeat-guard-task-03-plan-3
print -r -- "remote_cleanup=PASS $result_evidence invocation_count=1 provider_responses=15 edge_correlations=15 capacity_runs=3 configured_capacity=4 peak_in_flight=4 queued_pressure=present providers=idle harness=absent source=unchanged prior_artifacts=preserved"
REMOTE
```

Expected: exit 0 and only the sanitized cleanup PASS line; do not print `summary.json`, raw SSE, prompt, output, status payload, token, or token hash.

## Modified Files Summary

| File | Items |
|------|-------|
| `agent-task/m-openai-compatible-output-validation-filters/03_repeat_guard_s07_remote_evidence/CODE_REVIEW-cloud-G10.md` | REVIEW_OFR-S07-PINNED-CONTEXT-4-1, REVIEW_OFR-S07-PINNED-CONTEXT-4-2 |

## Dependencies and Execution Order

1. Preserve prior artifacts and prove plan-4 paths are fresh.
2. Confirm provider readiness, pinned feature source, clean `proto-socket/go`, tools, ports, and fresh focused tests.
3. Populate the isolated context, build one labeled image, and recreate only the Control Plane once with `--no-build`.
4. Require image/container provenance, current binary contract, Control Plane health/readiness, Edge reconnection, four connected nodes, and idle `3+1` provider snapshots.
5. If any prior gate fails, stop with `invocation_count=0` and do not mutate or retry.
6. If every gate passes, run the S07 Go test once in the foreground, validate its sanitized summary and cleanup, fill the active review, and stop for official review.

## Final Verification

PASS requires both direct provider status checks; pinned clean source/dependency identity; fresh focused package tests; exactly one isolated-context image build and one Control Plane recreate; matching source labels and running image identity; the current `provider_snapshots` binary/HTTP contract; four connected nodes; healthy/idle OneXPlayer and RTX5090 capacities `3+1`; protected SOPS authentication HTTP 200; exactly one attached foreground invocation exiting 0; 15 unique provider responses; 15 unique Edge correlations; three capacity rows with configured 4, peak in-flight 4, and queue pressure; an accepted sanitized `reproduced` fingerprint/offset or `not_reproduced` result; idle providers; absent harness; unchanged source; preserved old artifacts; and no raw secret/output in tracked files.

Run local workspace hygiene after recording the remote evidence:

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

Expected: `git diff --check` exits 0; status preserves unrelated user changes; grep finds no new raw credential or live response material in the active plan/review pair.

**After completing all code changes, fill implementation-owned sections in `CODE_REVIEW-*-G??.md`.**
