<!-- task=m-provider-resource-admission-ownership-alignment/16_capacity_smoke plan=1 tag=REVIEW_TEST -->

# Code Review Reference - REVIEW_TEST

> **[IMPLEMENTING AGENT — READ FIRST]** Fill implementation-owned sections, report `review-ready`, and stop. The implementation model must differ from Plan and Review. Do not review or start another agent.

## 개요

date=2026-07-22
task=m-provider-resource-admission-ownership-alignment/16_capacity_smoke, plan=1, tag=REVIEW_TEST

## 역할 모델

- Plan: `gpt-5.6-terra`
- Implementation: `gpt-5` (runtime identity; Plan 및 Review와 다름)
- Review: `gpt-5.6-sol` (runtime identity; Plan 및 Implementation과 다름)

> Runtime records each identity at its first role start. All three identities must differ.

## Roadmap Targets

- Milestone: `agent-roadmap/phase/operational-observability-provider-management/milestones/provider-resource-admission-ownership-alignment.md`
- Milestone link: [Milestone 문서](../../../agent-roadmap/phase/operational-observability-provider-management/milestones/provider-resource-admission-ownership-alignment.md)
- Task ids:
  - `capacity-smoke`: shared capacity-1 two-alias smoke, backend peak 1, online snapshot recovery, direct full-cycle evidence.
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- Prior `plan_local_G08_0.log` and `code_review_local_G08_0.log` in this task directory recorded FAIL.
- Required: wildcard metrics listener, unbounded curl/request cleanup, offline snapshot false-positive, auxiliary-only evidence. Suggested: remove `seq`. Nit: header has no stray prefix.

## 이 파일을 읽는 리뷰 에이전트에게

> **[REVIEW AGENT ONLY]** Review must differ from Plan/Implementation, must not edit source/tests or execute plan work, and finishes by leaving exactly one of a follow-up pair, `USER_REVIEW.md`, or `complete.log`.

## 구현 항목별 완료 여부

| 항목 | 완료 여부 |
|---|---|
| REVIEW_TEST-1 Disable temporary metrics listeners | [x] |
| REVIEW_TEST-2 Bound HTTP probes and cleanup | [x] |
| REVIEW_TEST-3 Online final recovery predicate | [x] |
| REVIEW_TEST-4 S11/direct full-cycle evidence | [x] |

## 구현 체크리스트

- [x] [REVIEW_TEST-1] Node `metrics.port <= 0`는 listener를 시작하지 않게 하고 smoke의 Edge/Node metrics를 모두 disabled로 고정한다.
- [x] [REVIEW_TEST-2] 모든 harness HTTP probe에 total timeout을 적용하고 request child PID까지 cleanup하며 hidden `seq` dependency를 없앤다.
- [x] [REVIEW_TEST-3] final status가 online configured `ornith-node`/`ornith-provider` identity와 capacity를 보존하면서 normal/long counters zero인 경우에만 pass하도록 한다.
- [x] [REVIEW_TEST-4] fresh Go/script/capacity smoke, auxiliary smoke, 그리고 direct dev Edge-Node full-cycle의 raw evidence를 review stub에 기록한다.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 채우고 review-ready를 보고한 뒤 현재 실행을 종료한다. code-review를 실행하거나 다음 에이전트를 시작하지 않는다.

## 코드리뷰 전용 체크리스트

> **[REVIEW AGENT ONLY]**

- [x] FAIL Required/Suggested/Nit가 source와 actual evidence에 모두 해소되었는지 확인한다.
- [x] Runtime Plan/Implementation/Review identities are `gpt-5.6-terra`, `gpt-5`, `gpt-5.6-sol` and all distinct.
- [x] `metrics.port <= 0` starts no Node listener; smoke does not allocate a metrics port and keeps Edge/Node metrics disabled.
- [x] every readiness/status/models/stats HTTP probe uses the common total-timeout helper; FIRST/SECOND request PIDs are initialized, killed, and waited on failure.
- [x] final zero predicate rejects the synthetic offline snapshot and requires connected `ornith-node`, available/healthy `ornith-provider`, capacity/long capacity 1, and normal/long zero counters.
- [x] `seq` is absent without adding a hidden required tool.
- [x] capacity smoke evidence and direct `scripts/dev/edge.sh`/`scripts/dev/node.sh` full-cycle output are distinct; raw output proves two same-session messages, payload order, terminal order, and commands.
- [x] PASS이면 `capacity-smoke` Roadmap Completion을 포함한 `complete.log`와 archive handoff를 만들되 roadmap을 직접 수정하지 않는다.

## 계획 대비 변경 사항

- 없음. 계획에 지정된 네 source/test 파일과 이 구현 기록만 변경했다.
- Control Plane view/handler, Edge service test, contract/spec/roadmap, 기본 config는 기존 dirty worktree 상태를 보존하고 수정하지 않았다.

## 주요 설계 결정

- `Module`의 production default는 계속 `observability.ServeMetrics`이며, test-only `WithMetricsStarter` seam으로 `metrics.port <= 0`에서 시작 호출이 없음을 회귀 검증했다.
- smoke의 Edge/Node metrics를 모두 `0`으로 고정하고 metrics 포트 할당을 제거했다. HTTP probe는 공통 1초 connect/2초 total helper를, 두 completion은 50초 total helper를 사용한다.
- `FIRST_PID`/`SECOND_PID`를 초기화하고 cleanup에서 kill/wait한다. completion subprocess는 `exec curl`로 대체해 PID가 요청 process를 가리킨다.
- fake backend `/hang`은 bounded probe의 실패/경과 시간을 검증한다. final predicate는 configured Node 연결, provider identity/status/health, normal/long capacity, 네 counter zero를 함께 요구하며 synthetic offline snapshot을 먼저 거부한다.

## 사용자 리뷰 요청

_선택된 Milestone `구현 잠금 > 결정 필요`가 구현을 막을 때만 채운다. 이 섹션을 포함한 모든 구현 소유 섹션을 채운 뒤 `review-ready`를 보고하고 종료한다. code-review를 실행하거나 review model을 시작하지 않는다._

- 상태: 없음
- 사유 유형: 없음
- 연결 대상: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 후속으로 해결할 수 없는 이유: 없음
- 재개 조건: 없음

## 리뷰어를 위한 체크포인트

- `module.go` test seam must retain `observability.ServeMetrics` as production default and only skip listener start for `port <= 0`.
- No default config, wire/schema, Control Plane view, contract/spec/roadmap, or root-owned dirty Edge service test may change.
- Inspect every curl call, all cleanup paths, arithmetic retry loop, and synthetic offline negative assertion rather than trusting prose.
- Treat `e2e-smoke.sh` as auxiliary. Require separate raw direct diagnostic output from both dev scripts before PASS.

## 검증 결과

### `gofmt -d apps/node/internal/bootstrap/module.go apps/node/internal/bootstrap/runtime_supervisor.go apps/node/internal/bootstrap/module_test.go`

exit 0; stdout/stderr 없음.

### `make proto`

exit 0.

```text
protoc --go_out=. --go_opt=module=iop --proto_path=. proto/iop/runtime.proto proto/iop/node.proto proto/iop/control.proto proto/iop/job.proto
```

`proto/gen/iop` 생성물 diff 및 untracked 생성물 없음.

### `go test -count=1 ./apps/node/internal/bootstrap`

exit 0.

```text
ok   iop/apps/node/internal/bootstrap  1.371s
```

`TestSupervisorDoesNotStartMetricsWhenPortDisabled`를 포함한다.

### `go test -count=1 ./apps/control-plane/...`

exit 0.

```text
ok   iop/apps/control-plane/cmd/control-plane  0.147s
ok   iop/apps/control-plane/internal/wire       1.494s
```

### `go test -count=1 ./apps/edge/internal/node ./apps/edge/internal/transport ./apps/edge/internal/service ./apps/edge/internal/bootstrap`

exit 0.

```text
ok   iop/apps/edge/internal/node       0.006s
ok   iop/apps/edge/internal/transport  4.746s
ok   iop/apps/edge/internal/service    5.860s
ok   iop/apps/edge/internal/bootstrap  5.322s
```

### `go test -count=1 ./apps/node/internal/transport ./apps/node/internal/bootstrap`

exit 0.

```text
ok   iop/apps/node/internal/transport  5.548s
ok   iop/apps/node/internal/bootstrap  1.582s
```

### `bash -n scripts/e2e-provider-capacity-smoke.sh`

exit 0; stdout/stderr 없음.

### `! rg -n '(^|[^[:alnum:]_])seq([^[:alnum:]_]|$)' scripts/e2e-provider-capacity-smoke.sh`

exit 0; 출력 없음.

### `./scripts/e2e-provider-capacity-smoke.sh`

exit 0.

```text
[provider-capacity-smoke] metrics=disabled bounded_probe_timeout_sec=2
[provider-capacity-smoke] offline_snapshot_rejected=true
[provider-capacity-smoke] aliases=ornith:35b,ornith-fast queue_observed=true
[provider-capacity-smoke] backend={"calls":2,"active":0,"peak":1}
[provider-capacity-smoke] final_provider=[{"node_id":"ornith-node","connected":true,"providers":[{"id":"ornith-provider","status":"available","health":"available","capacity":1,"in_flight":0,"queued":0,"long_context_capacity":1,"long_in_flight":0,"long_queued":0}]}]
[provider-capacity-smoke] PASS
```

`/hang` probe는 2초에 실패했고, cleanup은 initialized `FIRST_PID`/`SECOND_PID`를 포함해 terminate/wait하도록 구현됐다.

### `IOP_E2E_BIND_TIMEOUT=60 IOP_E2E_PROFILE=mock ./scripts/e2e-smoke.sh`

exit 0 (auxiliary-only).

```text
[e2e] NOTE: auxiliary smoke only; completion requires scripts/dev/edge.sh + scripts/dev/node.sh user-flow verification.
[e2e] Auxiliary smoke test PASSED.
```

mock profile에서 node 등록, `/nodes`, `/capabilities`, `/transport`, 동일 session foreground message 2회, `/sessions`, `/terminate-session`을 확인했다. 이 결과는 direct full-cycle을 대체하지 않는다.

### `bash -o pipefail -c './scripts/dev/edge-node-reconnect-diagnostic.sh 2>&1 | tee /tmp/iop-capacity-smoke-full-cycle.log'`

exit 0. Raw output: `/tmp/iop-capacity-smoke-full-cycle.log` (136 lines).

```text
[diagnostic] Message 1 completed
[diagnostic] Message 2 completed
edge> [node0-capabilities] ...
edge> [node0-transport] ...
edge> [node0-sessions] ...
edge> terminated session default node=node0
[diagnostic] PASS: 3 runs verified — payload sequence, one terminal after the last payload, Node==Edge; reconnect observed; all five command responses present.
```

원시 Edge/Node 출력은 `/nodes`, 같은 session의 두 foreground message, Node payload와 Edge payload의 순서 일치, 마지막 payload 뒤 단 한 번의 terminal, `/capabilities`, `/transport`, `/sessions`, `/terminate-session`을 담는다.

### `./scripts/e2e-long-context-admission-smoke.sh --preflight --out-dir /tmp/iop-capacity-live-preflight`

exit 3 — external live verification blocker이며 S11 성공 근거가 아니다.

```text
[long-admission-smoke] === PREFLIGHT ===
[long-admission-smoke] BLOCKER: provider /models 및 local Control Plane status가 unreachable
[long-admission-smoke] === PREFLIGHT BLOCKED ===
```

재개 조건: live provider endpoint와 local Control Plane status 경로가 준비된 환경에서 같은 preflight를 재실행한다. 상세 evidence는 `/tmp/iop-capacity-live-preflight`에 있다.

## 구현 상태

- `review-ready`
- 코드·mock capacity smoke·auxiliary smoke·직접 Edge-Node full-cycle은 통과했다.
- live preflight rc=3은 환경 차단으로 남아 있으며, code-review가 성공으로 재해석하면 안 된다.

---

> **[IMPLEMENTING AGENT — BEFORE SAVING]** Fill implementation-owned sections, report `review-ready`, and stop. Do not execute code-review or start another agent.

## 섹션 소유권

| Section | Owner | Note |
|---|---|---|
| Header, overview, Roadmap Targets, archive snapshot, checkpoints | Fixed | Implementation must not expand scope |
| 역할 모델 | Mixed | Runtime records distinct Implementation then Review identities |
| completion table, implementation checklist, changes, decisions, user review, verification output | Implementation | Record actual facts only |
| review checklist and verdict | Review | Implementation must not modify |
## 코드리뷰 결과

- 종합 판정: PASS
- 차원별 평가:
  - correctness: Pass
  - completeness: Pass
  - test coverage: Pass
  - API contract: Pass
  - code quality: Pass
  - implementation deviation: Pass
  - verification trust: Pass
  - spec conformance: Pass
- 발견된 문제: 없음
- 다음 단계: `complete.log`를 작성하고 pair와 task를 월별 archive로 이동한다.
