<!-- task=m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence plan=0 tag=API milestone-task=cleanup-observation -->

# Linked Single-request Observation Evidence

## For the Implementing Agent

Do not start until packets 14 and 15 each have `complete.log`. Add only the real-POST ingress/lifecycle correlation assertions and living-spec synchronization listed below, run every command, and fill `CODE_REVIEW-cloud-G03.md`. Do not alter production lifecycle or observation behavior.

## Background

Packets 14 and 15 provide deterministic timing ownership and bounded Edge/Node observers. S07 still needs one synthetic HTTP flow that links ingress, request-total, terminal, stage/tool/cleanup counts, and raw-free logs, plus current living-spec documentation that explicitly defers real Claude/Mac evidence.

## Analysis

### Files Read

- `apps/edge/internal/openai/server.go`
- `agent-spec/input/openai-compatible-surface.md`
- `agent-spec/runtime/edge-node-execution.md`

### SDD Criteria

- S07 requires linked request/stage/tool/cleanup/total timing and outcome evidence across the single-request path.
- S12 owns later actual Claude/Mac evidence; this packet must claim deterministic synthetic evidence only.
- D10 requires internal tools and raw values to remain absent from outer output and observation.

### Verification Context

- Packet 12's real marked POST fixture already exercises multiple internal tools.
- Packets 14 and 15 provide lifecycle metric accessors and captured raw-free logs.
- A focused endpoint test and deterministic documentation search are sufficient; no external runner is required.

### State and Concurrency Findings

- One marked POST must produce ingress=1, request-total=1, terminal=1, and the expected closed stage/tool/cleanup deltas.
- Correlation may use only the bounded generated execution id in logs and never a request-derived metric label.
- Production behavior is frozen by the predecessor packets; this closure packet changes tests and specs only.

### Test Coverage Gaps

- No real-POST assertion currently links ingress to lifecycle metrics and safe logs.
- Living specs do not yet state stage-pure/cardinality/privacy semantics for this path.

### Symbol References

- Extend packet 12's `single_request_handler_test.go` fixture; do not change handler production code.
- Consume the bounded metric/log accessors from packet 15.
- Keep external Claude/Mac timing evidence explicitly deferred to `claude-smoke`.

### Split Judgment

- This is the allowed integration/closure-only child: one endpoint evidence result and its matching living-spec statements.
- It has no production write set and must remain downstream of both predecessor children.

### Scope Rationale

- Include real-POST lifecycle delta/log privacy assertions and the two living-spec updates.
- Exclude all production code, new metrics/log fields, dashboards/ledger, and external smoke.

### Final Routing

- `evaluation_mode=isolated-reassessment`; build closures are true; scores 1/0/0/1/1 = G03.
- Finalizer `finalize-task-policy.sh` in `pair` mode selected `local-fit`, lane `local`, filename `PLAN-local-G03.md`.
- Build signals: `large_indivisible_context=false`; no matched loop-risk signatures, rework, or evidence-integrity failure.
- Review closures are true; scores 1/0/0/1/1 = G03; official review filename `CODE_REVIEW-cloud-G03.md`.

## Dependencies and Execution Order

1. Require packet 14's timing semantics and packet 15's production adapters.
2. Extend the real marked POST fixture with closed metric deltas and safe-log correlation assertions.
3. Synchronize input/runtime living specs with only the proven deterministic behavior.

## Implementation Checklist

- [ ] Prove a real marked Anthropic POST links ingress, request-total, terminal, stage/tool/cleanup counts, and raw-free correlation without public tool protocol.
- [ ] Synchronize input/runtime specs with stage-pure, cardinality, privacy, and deterministic evidence semantics while explicitly deferring external Claude/Mac smoke.
- [ ] Keep production handler, lifecycle, metrics, and log schemas unchanged.
- [ ] Run dependency, HTTP, package, vet, documentation, and whitespace verification.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Implementation Plan

### [API-3] Link ingress, lifecycle, and documented evidence

**Problem**

- S07 evidence needs one linked synthetic flow and specs describing pure-time/cardinality/privacy semantics; current living specs have only generic/route-01 observation.

**Solution**

Extend packet 12's real-POST test to snapshot ingress and lifecycle metrics, run multiple stages/tools plus cleanup, and assert deltas: ingress=1, request-total=1, terminal=1, and the expected stage/tool/cleanup counts. Capture logs using the safe generated correlation id and verify forbidden sentinels are absent. Keep actual Claude/Mac timing evidence explicitly deferred to `claude-smoke`.

**Modified Files and Checklist**

- [ ] `apps/edge/internal/openai/single_request_handler_test.go` — add ingress/lifecycle delta and raw-free correlation integration assertions.
- [ ] `agent-spec/input/openai-compatible-surface.md` — document ingress/terminal correlation and privacy.
- [ ] `agent-spec/runtime/edge-node-execution.md` — document stage-pure/tool/cleanup/total timing, labels, Node logs, and external-smoke deferral.

**Test Strategy**

- Add or extend `TestAnthropicSingleRequestObservation` using the real marked POST fixture and deterministic internal tools.

**Verification**

- `go test ./apps/edge/internal/openai -run 'TestAnthropicSingleRequestObservation' -count=1`
- `rg --sort path -n 'stage.*pure|tool.*duration|cleanup|total|raw|cardinality|Claude.*defer' agent-spec/input/openai-compatible-surface.md agent-spec/runtime/edge-node-execution.md`
- Expected: one synthetic request links all closed timing/outcome evidence and docs do not claim external smoke.

## Modified Files Summary

| File | Item |
|------|------|
| `apps/edge/internal/openai/single_request_handler_test.go` | API-3 |
| `agent-spec/input/openai-compatible-surface.md` | API-3 |
| `agent-spec/runtime/edge-node-execution.md` | API-3 |
| `agent-task/m-iop-owned-single-request-agent-execution/16+14,15_observation_evidence/CODE_REVIEW-cloud-G03.md` | API-3 |

## Final Verification

1. `test -f agent-task/m-iop-owned-single-request-agent-execution/14+05,12,13_observation_timing/complete.log || test "$(compgen -G 'agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/14+05,12,13_observation_timing/complete.log' | wc -l)" -eq 1`
2. `test -f agent-task/m-iop-owned-single-request-agent-execution/15+14_observation_adapters/complete.log || test "$(compgen -G 'agent-task/archive/*/*/m-iop-owned-single-request-agent-execution/15+14_observation_adapters/complete.log' | wc -l)" -eq 1`
3. `go test ./apps/edge/internal/openai -run 'TestAnthropicSingleRequestObservation' -count=1`
4. `go test ./apps/edge/internal/openai -count=1`
5. `go vet ./apps/edge/internal/openai`
6. `rg --sort path -n 'stage.*pure|tool.*duration|cleanup|total|raw|cardinality|Claude.*defer' agent-spec/input/openai-compatible-surface.md agent-spec/runtime/edge-node-execution.md`
7. `git diff --check`

Expected: packets 14 and 15 are uniquely complete; one synthetic request links bounded lifecycle evidence without raw values; the living specs defer external smoke; the affected package remains clean. Cached tests are not acceptable.

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