<!-- task=m-iop-owned-single-request-agent-execution/25+23,24_claude_smoke_qualification plan=19 tag=REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API milestone-task=workspace-binding,claude-smoke -->

# Code Review Reference - Claude thinking-redaction compatibility repair

> **[IMPLEMENTING AGENT — READ FIRST]** Complete the bounded source/contract repair, isolated dev rebuild, and provider-free verification. Fill every implementation-owned section, then stop. Do not invoke a model, retry Claude, append a verdict, archive files, or write completion evidence.

## Overview

date=2026-08-08
task=m-iop-owned-single-request-agent-execution/25+23,24_claude_smoke_qualification, plan=19, tag=REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API

## Archive Evidence Snapshot

- Prior pair: `plan_cloud_G10_18.log` / `code_review_cloud_G10_18.log`; verdict `FAIL`, Required R12, `review_rework_count=17`, `evidence_integrity_failure=false`.
- Fourth execution evidence: immutable `sole-live-4.rc-69`, `live_rc=69`, HTTP 400 before ingress, ingress/process delta zero, no internal stage/model output/result/manifest, and retry count zero.
- Provider-free before matrix: baseline 200; `redact-thinking-2026-02-12` 400; `thinking.display=omitted` 400; `thinking.display=summarized` 400; invalid display 400; ingress delta zero.
- Disposable candidate/runtime roots remain `/Users/toki/agent-work/iop-s12-validation-20260808/source` and `/Users/toki/agent-work/iop-s12-managed-validation-20260808`; canonical `/Users/toki/agent-work/iop-dev` is read-only for this repair.

## For the Review Agent

Verify exact installed-client evidence, bounded decoding/omission, adjacent fail-closed behavior, contract alignment, isolated build identity, and provider-free zero-activity status matrix. Append one verdict and routing signals, archive the pair, and materialize the matching next state. Never infer live authorization.

## Implementation Item Completion

| Item | Status |
|---|---|
| REVIEW_API-1 | [x] |
| REVIEW_API-2 | [x] |
| REVIEW_API-3 | [x] |
| REVIEW_API-4 | [x] |

## Implementation Checklist

- [x] Add the exact redacted-thinking beta and typed optional display enum validation.
- [x] Prove decoded Chat accepts supported variants, strips compatibility metadata, and rejects invalid display before provider wire.
- [x] Document native raw preservation and normalized non-authoritative omission.
- [x] Pass fresh local focused/race/harness/diff checks.
- [x] Synchronize only the changed repair files to the isolated source, rebuild/restart only disposable Edge, and verify exact provider-free after matrix with zero ingress/activity.
- [x] Fill implementation-owned sections in this file and stop for official review.

## Review-Only Checklist

> **[REVIEW AGENT ONLY]** Implementing agents must not modify or check this section.

- [ ] Append one verdict and verified routing signals.
- [ ] Verify exact scope, tests, contract, isolated runtime identity, status matrix, and no-live proof.
- [ ] Archive the active pair and materialize the verdict's next state.

## Deviations from Plan

- Local race verification had one initial unrelated failure in `TestSingleRequestArtifactLifecycle/artifact_first_and_tool_after_artifact_share_one_open` (`workspace cleanup is pending`). The exact subtest passed 10/10 under race, and the full requested race command then passed fresh. No service source was changed for this repair.
- Local `rsync` was unavailable, so the same three-file isolated synchronization was performed with exact-path `scp`. Scope and destination did not change.

## Key Design Decisions

- Accepted only `redact-thinking-2026-02-12`, `display="omitted"`, and `display="summarized"`, matching the exact installed-client builder/docs evidence. Other display values and types remain strict failures.
- Kept `Display` as decoded compatibility metadata. Existing field-by-field Chat conversion ignores it, so it cannot become provider, route, stage, workspace, tool-policy, or authorization input.
- Tested the no-display/redacted-beta path in the representative Claude request and both explicit-display paths separately, matching their mutually paired client behavior.
- Rebuilt/restarted only the disposable Edge. Canonical dev, Control Plane, Node, providers, four live guards, and success-only S12 owners were not mutated.

## Reviewer Checkpoints

- Confirm only the redacted-thinking beta and `omitted|summarized` display values were added.
- Confirm supported display is omitted from normalized Chat and grants no route/provider/workspace/tool-policy/authorization authority.
- Confirm invalid display plus adjacent `strict` and `eager_input_streaming` remain rejected before provider wire.
- Confirm only disposable isolated source/runtime changed and canonical dev remained untouched.
- Confirm all remote probes were provider-free, ingress/activity stayed zero, four guards were unchanged, and no model process/call/result/manifest appeared.

## Verification Results

### 1. Source, regression, and contract

- `supportedAnthropicBetas` now includes `redact-thinking-2026-02-12`. `anthropicThinkingConfig` has optional string `Display`; validation permits only empty, `omitted`, or `summarized`.
- `TestAnthropicChatBridgeClaudeCodeRequest` covers the redacted-thinking beta and confirms Anthropic compatibility headers are absent from normalized provider wire.
- `TestAnthropicChatBridgeThinkingDisplayCompatibility` covers both supported values and asserts neither `thinking` nor `display` appears in normalized Chat. The rejection table covers string `raw` and numeric display, and retains `strict`, `eager_input_streaming`, and unknown-beta failures before provider wire.
- The outer contract lists the beta and defines display enum, native raw preservation, normalized omission, and non-authoritative semantics without an S12 success claim.

### 2. Local fresh gates

Commands and results:

1. `gofmt -w apps/edge/internal/openai/anthropic_types.go apps/edge/internal/openai/anthropic_bridge_test.go` — exit 0.
2. `go test -count=1 ./apps/edge/internal/openai` — `ok  iop/apps/edge/internal/openai  8.350s`.
3. First `go test -count=1 -race ./apps/edge/internal/openai ./apps/edge/internal/service` — OpenAI passed 12.625s; service failed once in the unrelated artifact lifecycle subtest with `workspace cleanup is pending`.
4. `go test -count=10 -race ./apps/edge/internal/service -run 'TestSingleRequestArtifactLifecycle/artifact_first_and_tool_after_artifact_share_one_open'` — `ok  iop/apps/edge/internal/service  1.083s`.
5. Fresh full race rerun — OpenAI 12.319s; service 9.322s, both PASS.
6. `bash -n scripts/e2e-single-request-claude.sh && scripts/e2e-single-request-claude.sh --self-test` — exact self-test PASS message, exit 0.
7. `git diff --check` and focused secret/contract scans — PASS, no output/findings.

### 3. Disposable isolated rebuild

- Synchronized exactly `anthropic_types.go`, `anthropic_bridge_test.go`, and `anthropic-compatible-api.md` by exact-path `scp` to `/Users/toki/agent-work/iop-s12-validation-20260808/source`. Canonical `/Users/toki/agent-work/iop-dev` remained on `dev` and was not targeted.
- Remote focused/race results: OpenAI focused 8.824s; OpenAI race 12.377s; service race 9.821s.
- Rebuilt the candidate Edge with `go build -trimpath`; retained `iop-edge.pre-thinking-redaction`, `runtime-evidence.pre-thinking-redaction.json`, and `edge.log.pre-thinking-redaction`. Edge PID changed 8786 -> 16840; Control Plane 8782 and Node 8790 remained running.
- Runtime evidence was atomically refreshed to Edge digest `sha256:580f090213e67ff43d289272f37a5600a25aeeaf48a8879ce59609ec53c2fbf3` and worktree digest `sha256:7125f93e60ea5df36e191dfcbe77c70724f5eb1c926b2c4a39bf9958d20ffaf6`.
- Metrics listener, authenticated catalog/count-token routing, and Node reconnect remained healthy; certificate lifetime exceeded 900 seconds; recent Edge fatal/panic and Node reconnect/config-error counts were zero.

### 4. Provider-free compatibility and no-live proof

- Exact authenticated `/count_tokens` after matrix: baseline `200/positive-input-tokens`; redacted beta `200/positive-input-tokens`; display omitted `200/positive-input-tokens`; display summarized `200/positive-input-tokens`; invalid display `400/invalid-request-error`; tool strict `400/invalid-request-error`; tool eager input streaming `400/invalid-request-error`.
- Catalog was HTTP 200 with `iop-single-request-light` count 1. Ingress was 0 before/after every probe group; delta 0. Claude executable process count was 0.
- Harness output: `[single-request-claude-smoke] preflight passed without a Claude invocation`; preflight ingress delta 0, Claude processes 0, four finalized guards, zero started guards, output absent, workspace result absent.
- No `--run`, retry, Gemini/Ornith/Claude model call, direct provider request, manifest, or model output occurred.

### 5. Privacy and final hygiene

- SOPS caller material was decrypted only into a remote process variable, used only for authenticated IOP `/count_tokens`, catalog, and preflight probes, then unset. It was never printed, persisted, or sent to a provider.
- No token, key, prompt, raw response/model output, workspace content, or sensitive digest was added to source/task evidence. Targeted secret scan returned no findings.
- `git diff --check` passed. Active plan/review headers and archive snapshots match, task artifacts are unignored, and no implementation-owned placeholder remains.

---

> Implementer: fill every implementation-owned field, then stop for official review.

## Code Review Result

### Overall Verdict

FAIL

### Dimension Assessment

| Dimension | Assessment | Evidence |
|---|---|---|
| Correctness | Pass | The exact redacted-thinking beta and two display enum values decode, remain non-authoritative, and invalid neighbors fail closed. |
| Completeness | Fail | R12 is complete, but S12 still lacks a successful admitted Claude execution and its internal stage/workspace/terminal evidence. |
| Test coverage | Pass | Accepted header/display variants, normalized omission, invalid value/type, adjacent fields, local/remote focused/race suites, and live provider-free probes are covered. |
| API contract | Pass | Source and contract agree on accepted syntax, native raw behavior, normalized omission, and lack of routing/provider authority. |
| Code quality | Pass | The repair is one allowlist entry, one typed field, one closed enum validator, focused regressions, and bounded documentation. |
| Implementation deviation | Pass | Exact-path `scp` replaced unavailable `rsync`; the one unrelated race failure was transparently isolated, repeated 10 times, and followed by a passing full race run. |
| Verification trust | Pass | Local/remote tests, rebuilt Edge identity, exact 200/200/200/200 and 400/400/400 matrix, preflight, zero ingress/process, and unchanged guards agree. |
| Spec conformance | Fail | SDD S12 still requires ingress 1, Gemini -> Ornith-fast -> Gemini, timings, workspace verification/cleanup, and one terminal. |

### Findings

- Required R13 — `agent-roadmap/phase/knowledge-tool-optimization-extension/milestones/iop-owned-single-request-agent-execution.md:90`: the newly proven Claude 2.1.177 thinking-redaction compatibility boundary is repaired and provider-free qualified in the disposable runtime, but S12 still requires one real Claude-through-IOP request. The user's latest authorization was consumed exactly once as `sole-live-4.rc-69`; require a new explicit authorization before creating `sole-live-5.started` -> `sole-live-5.rc-<live_rc>` and invoking once. Keep caller auth SOPS-only/in-memory, Gemini plan/review and Ornith-fast work IOP-owned, and prohibit retry or direct provider requests.

### Routing Signals

- `evaluation_mode=isolated-reassessment`
- `verdict=FAIL`
- `review_rework_count=18`
- `evidence_integrity_failure=false`
- `next_state=user-review`
