# Complete - m-provider-resource-admission-ownership-alignment/13+09_disconnect_queue_settlement

## 완료 일시

2026-07-21

## 요약

authoritative disconnect queue settlement의 surviving-provider regression을 실제 queued-disconnect 분기로 결정화했고, 2회 리뷰 루프 끝에 최종 PASS했다.

## 루프 이력

| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `plan_local_G06_0.log` | `code_review_local_G06_0.log` | FAIL | surviving-provider test가 disconnect 전에 node-2로 즉시 dispatch되어 SDD S13 queued fallback 분기를 검증하지 못함 |
| `plan_local_G04_1.log` | `code_review_local_G04_1.log` | PASS | queued pressure를 먼저 증명하고 survivor 등록 단독으로는 완료되지 않은 뒤 authoritative disconnect만으로 fallback됨을 반복·race 검증함 |

## 구현/정리 내용

- `TestSubmitRunModelQueueSurvivingProviderFallbackAfterDisconnect`의 초기 live registry를 node-1로 제한해 run-2가 반드시 queue에 들어가게 했다.
- `ListNodeSnapshots()`의 provider in-flight/candidate-pressure를 bounded polling해 disconnect 전 queued 상태와 survivor 등록 단독의 non-completion을 검증했다.
- `UnregisterIfClient`가 반환한 current-owner generation으로 `HandleNodeDisconnect`를 호출해 node-2 fallback, queue/lease counter 회복, terminal event idempotence를 검증했다.

## 최종 검증

- `gofmt -d apps/edge/internal/service/queue_dispatch_test.go` - PASS; 출력 없음.
- `git diff --check -- apps/edge/internal/service/queue_dispatch_test.go` - PASS; 출력 없음.
- `go test -count=20 -timeout 120s -run '^TestSubmitRunModelQueueSurvivingProviderFallbackAfterDisconnect$' -v ./apps/edge/internal/service` - PASS; 20/20, `ok iop/apps/edge/internal/service 0.117s`.
- `go test -race -count=1 -timeout 120s -run '^(TestProviderPoolDisconnectAuthoritativeSettlementNoLeak|TestProviderPoolLastProviderDisconnectTerminalSettlement|TestSubmitRunModelQueueSurvivingProviderFallbackAfterDisconnect|TestSubmitRunModelQueueLastProviderDisconnectReturnsUnavailable)$' ./apps/edge/internal/service` - PASS; race warning 없음, `ok ... 1.126s`.
- `go test -count=1 -timeout 120s ./apps/edge/...` - PASS; Edge 전체 package 통과.
- `go test -count=1 -timeout 180s ./...` - FAIL (현 task 비차단); 변경 없는 `apps/node/internal/adapters/cli` tests 3개만 실패했고, 좁힌 재실행에서 2개는 PASS로 바뀌었으며 `TestCLIExecuteOneShot_TimeoutEmitsTimeoutMessage` `-count=3`은 PASS/FAIL/PASS로 timing flake가 재현됨. G04 write set과 Edge 회귀는 통과함.
- `IOP_E2E_PROFILE=mock ./scripts/e2e-smoke.sh` - BLOCKED (현 task 비차단); 동적 port `34181`에서 기본 10초 bind 대기 내 Edge startup이 완료되지 않아 exit 1.
- `IOP_E2E_BIND_TIMEOUT=60 IOP_E2E_PROFILE=mock ./scripts/e2e-smoke.sh` - PASS; 동일 mock flow가 port `36355`에서 registration, foreground 2회, background run, capabilities, transport, sessions, terminate-session, shutdown까지 통과해 기본 실패를 startup-timeout으로 분류함.

## Roadmap Completion

- 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)
- Completed task ids:
  - `disconnect-queue-resolution`: PASS; evidence=`agent-task/archive/2026/07/m-provider-resource-admission-ownership-alignment/13+09_disconnect_queue_settlement/plan_local_G04_1.log`, `agent-task/archive/2026/07/m-provider-resource-admission-ownership-alignment/13+09_disconnect_queue_settlement/code_review_local_G04_1.log`; verification=`go test -count=20 -timeout 120s -run '^TestSubmitRunModelQueueSurvivingProviderFallbackAfterDisconnect$' -v ./apps/edge/internal/service`, `go test -race -count=1 -timeout 120s -run '^(TestProviderPoolDisconnectAuthoritativeSettlementNoLeak|TestProviderPoolLastProviderDisconnectTerminalSettlement|TestSubmitRunModelQueueSurvivingProviderFallbackAfterDisconnect|TestSubmitRunModelQueueLastProviderDisconnectReturnsUnavailable)$' ./apps/edge/internal/service`, `go test -count=1 -timeout 120s ./apps/edge/...`, `IOP_E2E_BIND_TIMEOUT=60 IOP_E2E_PROFILE=mock ./scripts/e2e-smoke.sh`
- Not completed task ids: 없음

## 잔여 Nit

- 없음

## 후속 작업

- 없음
