<!-- task=m-iop-hot-path-one-shot-execution/19+17,18_observation_lifecycle plan=0 tag=API milestone-task=route-observability -->

# Code Review Reference - API

> **[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.

## Overview

date=2026-08-03
task=m-iop-hot-path-one-shot-execution/19+17,18_observation_lifecycle, plan=0, tag=API

## For the Review Agent

1. Append verdict and routing signals.
2. Archive `CODE_REVIEW-cloud-G09.md` → `code_review_cloud_G09_0.log` and `PLAN-local-G08.md` → `plan_local_G08_0.log`.
3. On PASS write `complete.log` and move to `agent-task/archive/YYYY/MM/m-iop-hot-path-one-shot-execution/19+17,18_observation_lifecycle/`; otherwise write the directed next state.
4. Preserve/report `milestone-task=route-observability` on PASS.
5. Complete the review-only checklist at the final location.

## Implementation Item Completion

| Item | Status |
|---|---|
| API-1 Lifecycle emission wiring | [ ] |
| API-2 Lifecycle and raw-free evidence | [ ] |

## Implementation Checklist

- [ ] [API-1] Wire the predecessor observation schema across admission, stage attempts/transitions, terminal, cleanup, and orphan responsibility while isolating observation failure from request behavior.
- [ ] [API-2] Add lifecycle joins, ordering, cardinality, exactly-once, and seeded raw/secret absence regressions and run the child verification commands.
- [ ] Fill implementation-owned sections in CODE_REVIEW-*-G??.md with actual implementation notes and verification output.

## Review-Only Checklist

- [ ] Append one verdict of `PASS`, `WARN`, or `FAIL` and verified `review_rework_count`, `evidence_integrity_failure`.
- [ ] Verify verdict, dimension assessment, and Required/Suggested/Nit classifications match.
- [ ] Archive the active review to `code_review_cloud_G09_0.log`.
- [ ] Archive the active plan to `plan_local_G08_0.log`.
- [ ] Verify the Agent-Ops managed block in `.gitignore`.
- [ ] If PASS, write `complete.log` from the standard template and leave no active `.md` files.
- [ ] If PASS, move the task directory to the dated archive and update this checklist at the final location.
- [ ] If PASS, preserve/report `milestone-task=route-observability` without directly editing the roadmap.
- [ ] If PASS, remove the active parent only when no siblings/files remain.
- [ ] If WARN/FAIL, write the next filesystem state and do not write `complete.log`.

## Deviations from Plan

_Implementer records actual deviations or `none`._

## Key Design Decisions

_Implementer records actual decisions._

## Reviewer Checkpoints

- Verify every intended lifecycle boundary emits one typed event with joined request/stage/attempt state.
- Verify high-cardinality ids remain log-only and exact metric labels remain bounded.
- Verify raw/secret sentinel absence and observation failure isolation.

## Verification Results

### Targeted

Command: `go test -race -count=1 ./apps/edge/internal/openai -run 'TestHotPathObservation|TestHotPathMetric|TestHotPath(EndpointTerminalMatrix|CancelCompleteRace|Cleanup)'`

_Paste actual stdout/stderr and exit status._

### SDD common

Command: `go test -race -count=1 ./packages/go/streamgate ./packages/go/config ./apps/edge/internal/openai ./apps/edge/internal/service`

_Paste actual stdout/stderr and exit status._

### Diff

Command: `git diff --check`

_Paste actual stdout/stderr and exit status._

---

> **[IMPLEMENTING AGENT — BEFORE SAVING]** Fill every implementation-owned section and leave review-only sections unchanged.

## Section Ownership

| Section | Owner | Note |
|---|---|---|
| Header, Overview, Review Agent Instructions | Fixed | Implementer must not finalize |
| Implementation Item Completion, Implementation Checklist | Implementer checks only | Text/order stays fixed |
| Review-Only Checklist | Review agent | Implementer must not modify |
| Deviations, Key Design Decisions | Implementer | Record actual content |
| Reviewer Checkpoints | Fixed | Reviewer verifies |
| Verification Results | Implementer fills output | Command changes require deviation |
| Code Review Result | Review agent appends | Not included in stub |
