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

# Repair Claude prompt-caching-scope compatibility without another live call

## For the Implementing Agent

Repair the exact Claude Code 2.1.177 pre-ingress beta mismatch identified after Plan 14. Add bounded support for `prompt-caching-scope-2026-01-05`, prove that it grants no routing/workspace authority and does not leak into normalized Gemini/Ornith provider payloads, update the external compatibility contract, rebuild only the disposable managed Edge, and repeat provider-free IOP gates. Do not invoke Claude, Gemini, Ornith, or any provider directly. Both existing live guards are immutable, and the current user authorization has already been consumed. Fill every implementation-owned review section and leave finalization to official review.

## Background

Plan 14 executed exactly one newly authorized Claude Code call through IOP. It returned `live_rc=69`, class `api-rejected`, reason `http-400`, before accepted ingress; `sole-live-2.rc-69` now preserves that cardinality together with the older `sole-live.rc-69`. All lifecycle, provider-stage, workspace, terminal, and model-output counters remained zero, and no retry occurred.

Static inspection of the installed canonical Claude 2.1.177 executable established the exact default request path. `ANTHROPIC_BASE_URL` changes the destination but not Claude's internal provider family, so the CLI remains on its first-party beta path. For the custom non-Haiku public model in noninteractive `--print` mode, it adds `prompt-caching-scope-2026-01-05`; the current Edge allowlist lacks that value. A provider-free authenticated IOP `count_tokens` request containing the bounded default beta set returns HTTP 400 on the current managed Edge, reproducing the boundary without generation.

## Archive Evidence Snapshot

- Prior pair: `plan_cloud_G10_14.log` / `code_review_cloud_G10_14.log`; verdict `FAIL`, `review_rework_count=13`, `evidence_integrity_failure=false`.
- Required R8: add only the missing prompt-caching-scope compatibility beta, keep it non-authoritative/non-forwarded, update the contract, and prove the exact provider-free request changes from HTTP 400 to HTTP 200 with generation counters unchanged.
- Managed root: `/Users/toki/agent-work/iop-s12-managed-validation-20260808`; isolated source `/Users/toki/agent-work/iop-s12-validation-20260808/source`; canonical `/Users/toki/agent-work/iop-dev` remains read-only.
- Caller credential remains remote SOPS `tokens.toki-dev-cline`, used only for authenticated caller-to-IOP provider-free probes and never printed, persisted, or passed to a provider.

## Analysis

### Exact Root Cause and Scope

- Edge validates every `Anthropic-Beta` token against `supportedAnthropicBetas` before admission. `prompt-caching-scope-2026-01-05` is absent, so the exact provider-free probe returns HTTP 400 before counting or generation.
- Claude's request builder adds that beta whenever its API provider family is first-party and experimental betas are enabled. A custom IOP base URL makes `T3()` false but leaves `l8()` as first-party, so the beta is still present.
- `speed` is emitted only in fast mode, which this invocation did not use. `diagnostics` requires the first-party Anthropic hostname capability check, which is false for the IOP base URL. Neither field belongs in this repair.
- The compatibility beta is permission metadata only. IOP must not interpret it as cache, route, stage, provider, workspace, or authorization authority. Existing strict rejection for all other unknown betas remains intact.

### Acceptance and Safety Boundary

- Add exactly `prompt-caching-scope-2026-01-05` to the beta allowlist.
- Extend the Claude Code bridge test to include the beta and prove normalized Gemini Chat output is unchanged. Keep a negative unknown-beta test.
- Document the beta as accepted compatibility metadata, ignored by normalized Chat routing, with raw provider tunnel semantics unchanged.
- Fresh local race tests, syntax/self-test, contract/source assertions, redaction scan, and diff checks must pass.
- Rebuild/restart only the disposable managed Edge and atomically refresh current runtime identity evidence if the binary changes.
- The exact authenticated provider-free `count_tokens` request must return HTTP 200; selected catalog remains one model; ingress/lifecycle/hot-path dispatch/terminal/model-output counters and Claude process count remain zero.
- Do not create another live guard, invoke Claude `--run`, generate provider output, change the workspace result, publish S12 success evidence, or update success-only qualification statements.

### Split Judgment

This is one indivisible ingress-contract repair: allowlist, normalized-bridge proof, external contract, and provider-free managed validation describe the same beta boundary. Splitting them would permit code and contract/runtime evidence to disagree.

## Finding Resolution Map

| Finding | Mode | Exact fix / evidence | Changed precondition |
|---|---|---|---|
| R8 | direct-fix | `apps/edge/internal/openai/anthropic_types.go`, `apps/edge/internal/openai/anthropic_bridge_test.go`, `agent-contract/outer/anthropic-compatible-api.md`; exact managed IOP count-token probe | Claude's deterministic prompt-caching-scope beta changes from pre-ingress HTTP 400 to provider-free HTTP 200 without routing or generation authority. |

## Dependencies and Execution Order

1. Add the single beta allowlist entry and update focused positive/negative bridge tests.
2. Update the external Anthropic compatibility contract with bounded semantics.
3. Run fresh local verification and synchronize only reviewed files to the isolated macOS source.
4. Rebuild/restart the disposable managed Edge, refresh runtime identity evidence, and run catalog plus exact provider-free count-token gates.
5. Confirm both live guards and all zero-generation/artifact invariants, then fill implementation review evidence.

## Plan Items

### 1. COMPAT-1 — accept the deterministic Claude beta only

**Solution:** add `prompt-caching-scope-2026-01-05` to `supportedAnthropicBetas`. Do not add speculative beta values or request fields, and retain strict rejection of an unrelated unknown beta.

**Files:**

- [ ] `apps/edge/internal/openai/anthropic_types.go`

### 2. BRIDGE-2 — prove normalized provider behavior is unchanged

**Solution:** include the new beta in the representative Claude Code request and assert that the request remains accepted while no prompt-caching-scope control appears in the normalized Gemini Chat body or gains routing authority. Preserve the before-wire unknown-beta rejection test.

**Files:**

- [ ] `apps/edge/internal/openai/anthropic_bridge_test.go`

### 3. CONTRACT-3 — synchronize external compatibility semantics

**Solution:** list the beta among accepted compatibility headers and explicitly state that it is advisory/non-authoritative and omitted from normalized Chat provider requests; raw provider tunnel behavior remains governed by the existing tunnel contract.

**Files:**

- [ ] `agent-contract/outer/anthropic-compatible-api.md`

### 4. PROVIDER-FREE-4 — prove the repaired boundary through IOP

**Solution:** run fresh local gates, rebuild only the disposable managed Edge, refresh current runtime evidence, and repeat the exact SOPS-authenticated catalog/count-token probes. Require HTTP 200 and zero generation/activity deltas. Never run Claude or a provider.

**Evidence:**

- [ ] Exact prompt-caching-scope count-token request returns HTTP 200 through IOP.
- [ ] Ingress/lifecycle/hot-path dispatch/terminal/model-output and Claude child deltas remain zero.
- [ ] Both existing live guards, absent result/manifest, canonical dev identity, and cleanup state remain unchanged.

### 5. REVIEW-EVIDENCE-5 — record bounded outcomes

**Solution:** fill the active review with exact code/test/contract outcomes, managed runtime identities, provider-free statuses/counters, no-live proof, deviations, and remaining external-execution boundary.

**File:**

- [ ] `agent-task/m-iop-owned-single-request-agent-execution/25+23,24_claude_smoke_qualification/CODE_REVIEW-cloud-G10.md`

## Implementation Checklist

- [ ] Add only the missing prompt-caching-scope beta and retain strict unknown-beta rejection.
- [ ] Prove normalized Gemini/Ornith routing and payload authority are unchanged.
- [ ] Synchronize the external Anthropic compatibility contract.
- [ ] Pass fresh local and managed macOS provider-free IOP gates.
- [ ] Preserve both live guards and perform no Claude/provider generation or retry.
- [ ] Leave success-only S12 evidence/spec qualification deferred.
- [ ] Fill implementation-owned review evidence and stop for official review.

## Modified Files Summary

| File | Reason |
|---|---|
| `apps/edge/internal/openai/anthropic_types.go` | Accept the deterministic Claude prompt-caching-scope beta |
| `apps/edge/internal/openai/anthropic_bridge_test.go` | Prove acceptance, normalized omission, and retained unknown-beta rejection |
| `agent-contract/outer/anthropic-compatible-api.md` | Document bounded compatibility semantics |
| `agent-task/m-iop-owned-single-request-agent-execution/25+23,24_claude_smoke_qualification/CODE_REVIEW-cloud-G10.md` | Record implementation-owned verification evidence |

## Final Verification

1. `gofmt -w apps/edge/internal/openai/anthropic_types.go apps/edge/internal/openai/anthropic_bridge_test.go`.
2. Focused Anthropic beta/Claude bridge tests, then `go test -count=1 -race ./apps/edge/internal/openai ./apps/edge/internal/service`.
3. `bash -n scripts/e2e-single-request-claude.sh`, harness `--self-test`, contract/source assertions, secret/redaction scan, placeholder scan, and `git diff --check`.
4. Sync only reviewed source to the isolated macOS source; run focused package tests; rebuild/restart the disposable Edge and pass config check.
5. Authenticated IOP catalog HTTP 200 with selected-model count 1 and exact prompt-caching-scope `count_tokens` HTTP 200; all single-request/provider generation counters and Claude process delta remain zero.
6. Verify `sole-live.rc-69` and `sole-live-2.rc-69` unchanged, no new guard, no workspace result/manifest, no S12 success-only updates, and canonical dev unchanged.

## Final Routing

- `evaluation_mode=isolated-reassessment`
- `finalizer=finalize-task-policy.sh`, `finalizer_mode=pair`
- build scores `2/2/2/2/2` => `G10`, `base_route_basis=grade-boundary`
- `large_indivisible_context=true`; matched risks: `temporal_state`, `concurrent_consistency`, `boundary_contract`, `variant_product`; count 4
- `review_rework_count=13`, `evidence_integrity_failure=false`; risk/recovery boundaries matched without replacing grade basis
- build `worker/cloud/G10`, `PLAN-cloud-G10.md`; review `review/cloud/G10`, `CODE_REVIEW-cloud-G10.md`
