<!-- task=m-agent-task-runtime-target-selector/04+03_failover_budget plan=17 tag=REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API -->

# Code Review Reference - REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_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 `구현 체크리스트`; 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 (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume.
> Follow the ownership table at the bottom of this file for which sections you own.

## 개요

date=2026-07-26
task=m-agent-task-runtime-target-selector/04+03_failover_budget, plan=17, tag=REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API

## Roadmap Targets

- Milestone: `agent-roadmap/phase/automation-runtime-bridge/milestones/agent-task-runtime-target-selector.md`
- Milestone link: [Milestone 문서](agent-roadmap/phase/automation-runtime-bridge/milestones/agent-task-runtime-target-selector.md)
- Task ids:
  - `time-route`: local-G07~G08 KST 주야간 최초 target
  - `context-failover`: canonical persisted decision과 Gemini↔Laguna logical failover
  - `failure-budget`: target 전환 전후 동일 stage 10회 실패 예산
  - `selfcheck-policy`: 실제 worker 완료 target 기반 selfcheck
- Completion mode: check-on-pass

## Archive Evidence Snapshot

- 직전 계획: `agent-task/m-agent-task-runtime-target-selector/04+03_failover_budget/plan_local_G08_16.log`.
- 직전 리뷰: `agent-task/m-agent-task-runtime-target-selector/04+03_failover_budget/code_review_cloud_G08_16.log` — FAIL, Required 4 / Suggested 0 / Nit 0.
- 영향 파일: `execution_target_policy.py`, `select_execution_target.py`, `test_execution_target_policy.py`, `test_select_execution_target.py`, `test_dispatch.py`.
- 검증 evidence: focused selector 9, dispatcher 23, lifecycle 28, 전체 192 tests는 PASS했으나 fixed-input environment 및 prior metadata tamper focused 재현은 실패했다.
- 닫힌 carryover: logical context 검증과 failover decision/history commit 원자성.
- 남은 carryover: S01/S02/S07/S10 및 네 Roadmap Target evidence.

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

> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.

각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.

1. 판정을 append한다.
2. `CODE_REVIEW-cloud-G08.md` → `code_review_cloud_G08_17.log`, `PLAN-local-G08.md` → `plan_local_G08_17.log`로 아카이브한다.
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-agent-task-runtime-target-selector/04+03_failover_budget/`로 이동한다. WARN/FAIL이면 code-review skill이 요구하는 다음 filesystem state를 완전히 작성한다.
4. PASS이고 task group이 `m-<milestone-slug>`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다.
5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다.

---

## 구현 항목별 완료 여부

| 항목 | 완료 여부 |
|------|---------|
| REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-1 Deterministic route와 canonical decision evidence | [x] |
| REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-2 S07 실제 budget/reopen/reset evidence | [x] |
| REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-3 S10 실제 completing-target selfcheck evidence | [x] |

## 구현 체크리스트

- [x] REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-1 hidden route input을 제거하고 persisted canonical decision evidence 전체를 fail-closed 검증한다.
- [x] REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-2 실제 primary 1 + alternate 9, reopen, audit, stage 분리와 success reset을 검증한다.
- [x] REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_REVIEW_API-3 실제 Gemini→Laguna, Laguna→Gemini, cloud completion에서 completing-target selfcheck lifecycle을 검증한다.
- [x] `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 실제 변경 내용과 검증 출력으로 채운다.

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

> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.

- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_cloud_G08_17.log`로 아카이브한다.
- [ ] active `PLAN-*-G??.md`를 `plan_local_G08_17.log`로 아카이브한다.
- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [ ] PASS이면 active task 디렉터리 `agent-task/m-agent-task-runtime-target-selector/04+03_failover_budget/`를 `agent-task/archive/YYYY/MM/m-agent-task-runtime-target-selector/04+03_failover_budget/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-agent-task-runtime-target-selector/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [ ] WARN/FAIL이면 code-review skill의 판정에 맞는 다음 filesystem state를 작성하고 `complete.log`를 작성하지 않는다.

## 계획 대비 변경 사항

없음. 계획서에 명시된 대로 구현 및 테스트 완료.

## 주요 설계 결정

1. **Hidden Route Input 제거 및 Deterministic Routing 보장**
   - `execution_target_policy.py`에서 `IOP_FORCE_GEMINI_TODAY` 환경변수 처리 로직 및 `import os` 의존성을 제거하여 오직 `evaluated_at`의 KST 시간대 window로만 경로를 선택하도록 수정함.
   - `select_execution_target.py`에서 `_VALID_TIME_WINDOWS` 내 `"manual-gemini-today"`를 삭제하고 `_validate_prior_candidate_identity`에서 `evaluated_at`의 timezone-aware 여부를 엄격 검증.
   - prior decision의 `rule_id`, `policy_priority`, `reason_codes`, `time_window`, 후보 목록이 재계산된 canonical policy와 완전히 일치하지 않으면 `malformed_prior_decision`으로 거부하도록 함.

2. **S07 실제 Failover Budget / Reopen / Stage Reset 검증**
   - `test_dispatch.py`의 `DynamicFailoverBudgetTest`에 primary(Gemini) 1회 실패 + alternate(Laguna) 9회 실패로 총 10회 실패 예산 소진 및 reopen 전후 history/audit field 검증 구현.
   - worker stage 성공 시 worker budget만 reset되고 기존 review stage budget은 유지됨을 `test_success_resets_only_current_stage_budget`으로 검증.

3. **S10 Actual Completing Target 기반 Selfcheck Lifecycle 검증**
   - `DispatcherCanonicalFailoverIntegrationTest`에서 `run_worker()`와 `run_escalating()`을 실제 실행하며 `invoke()`만 결정론적 mock으로 처리.
   - Day Gemini→Laguna success 시에만 `selfcheck` 단계 진입 및 pinned Laguna selfcheck 수행 확인, Night Laguna→Gemini 및 Cloud success 시에는 selfcheck를 스킵하고 `review` 단계로 이동함을 검증.

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

- 같은 task/evaluated-at의 canonical route가 process 환경과 무관하고 야간 최초 target이 Laguna인가.
- prior decision의 aware evaluated-at 및 `rule_id`/`policy_priority`/`reason_codes`/`time_window`/candidates가 canonical policy와 모두 일치해야 resume/failover하는가.
- 실제 invocation이 primary 1 + alternate 9이고 reopen 전후 worker budget/history/audit가 보존되며 success reset은 현재 stage에만 적용되는가.
- 실제 Gemini→Laguna completion만 pinned Laguna selfcheck를 실행하고 Laguna→Gemini/cloud completion은 생략하며 duplicate initial history가 없는가.

## 검증 결과

각 명령을 정확히 실행하고 actual stdout/stderr와 exit code를 아래에 기록한다. 명령을 바꾸면 `계획 대비 변경 사항`에 대체 명령과 이유를 먼저 기록한다.

### Deterministic policy와 canonical selector evidence

```bash
env -u IOP_FORCE_GEMINI_TODAY python3 -m unittest agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorRouteMatrixTests agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests -v
```

결과: (Exit Code: 0)
```
test_invalid_inputs_are_rejected (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_invalid_inputs_are_rejected) ... ok
test_local_g07_g08_candidate_order_uses_kst_boundaries (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_local_g07_g08_candidate_order_uses_kst_boundaries) ... ok
test_local_g07_route_uses_kst_boundaries (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_local_g07_route_uses_kst_boundaries) ... ok
test_policy_is_unaffected_by_process_environment_variables (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_policy_is_unaffected_by_process_environment_variables) ... ok
test_review_matrix_is_fixed_to_codex (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_review_matrix_is_fixed_to_codex) ... ok
test_worker_grade_matrix_has_no_gaps (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_execution_target_policy.ExecutionTargetPolicyTests.test_worker_grade_matrix_has_no_gaps) ... ok
test_cli_input_error_is_stderr_json_without_stdout (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_cli_input_error_is_stderr_json_without_stdout) ... ok
test_deterministic_output_for_fixed_clock (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_deterministic_output_for_fixed_clock) ... ok
test_failover_requires_qualified_failure_class (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_failover_requires_qualified_failure_class) ... ok
test_invalid_filenames_and_grades_rejected (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_invalid_filenames_and_grades_rejected) ... ok
test_malformed_header_rejected (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_malformed_header_rejected) ... ok
test_repeated_input_is_byte_stable (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_repeated_input_is_byte_stable) ... ok
test_resume_pins_prior_target_across_time (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_resume_pins_prior_target_across_time) ... ok
test_resume_requires_matching_prior_decision (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_resume_requires_matching_prior_decision) ... ok
test_stage_inference_and_mismatch (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_stage_inference_and_mismatch) ... ok
test_work_unit_id_stable_across_body_changes (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_work_unit_id_stable_across_body_changes) ... ok
test_worker_contract_shape_and_types (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorContractTests.test_worker_contract_shape_and_types) ... ok
test_candidate_rank_is_single_per_time_window (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorRouteMatrixTests.test_candidate_rank_is_single_per_time_window) ... ok
test_local_g07_g08_use_kst_boundaries (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorRouteMatrixTests.test_local_g07_g08_use_kst_boundaries) ... ok
test_review_route_matrix_is_codex (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorRouteMatrixTests.test_review_route_matrix_is_codex) ... ok
test_worker_route_matrix_through_selector (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorRouteMatrixTests.test_worker_route_matrix_through_selector) ... ok
test_cross_boundary_failover_resumes_pinned_decision (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests.test_cross_boundary_failover_resumes_pinned_decision) ... ok
test_generic_failure_and_exhausted_or_used_candidate_fail_closed (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests.test_generic_failure_and_exhausted_or_used_candidate_fail_closed) ... ok
test_qualified_failover_uses_only_unused_eligible_candidate (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests.test_qualified_failover_uses_only_unused_eligible_candidate) ... ok
test_tampered_prior_decision_rejected (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests.test_tampered_prior_decision_rejected) ... ok
test_unknown_is_admitted_once_and_no_bounce_remains (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_select_execution_target.SelectorFailoverContractTests.test_unknown_is_admitted_once_and_no_bounce_remains) ... ok

----------------------------------------------------------------------
Ran 26 tests in 0.175s

OK
```

### S07 budget lifecycle

```bash
env -u IOP_FORCE_GEMINI_TODAY python3 -m unittest agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DynamicFailoverBudgetTest agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.RouteDecisionPersistenceTest -v
```

결과: (Exit Code: 0)
```
test_context_package_keeps_artifacts_and_blocks_cross_adapter_native_session (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DynamicFailoverBudgetTest.test_context_package_keeps_artifacts_and_blocks_cross_adapter_native_session) ... ok
test_primary_and_alternate_share_budget_across_reopen (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DynamicFailoverBudgetTest.test_primary_and_alternate_share_budget_across_reopen) ... ok
test_success_resets_only_current_stage_budget (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DynamicFailoverBudgetTest.test_success_resets_only_current_stage_budget) ... ok
test_malformed_or_exhausted_state_blocks_only_its_task (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.RouteDecisionPersistenceTest.test_malformed_or_exhausted_state_blocks_only_its_task) ... ok
test_rejects_tampered_canonical_target_and_selector_load_error (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.RouteDecisionPersistenceTest.test_rejects_tampered_canonical_target_and_selector_load_error) ... ok
test_reopen_body_edit_and_generation_reset_preserve_or_reset_pin (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.RouteDecisionPersistenceTest.test_reopen_body_edit_and_generation_reset_preserve_or_reset_pin) ... ok
test_resume_keeps_pin_across_kst_boundary (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.RouteDecisionPersistenceTest.test_resume_keeps_pin_across_kst_boundary) ... ok

----------------------------------------------------------------------
Ran 7 tests in 0.114s

OK
```

### S10 completing-target lifecycle

```bash
env -u IOP_FORCE_GEMINI_TODAY python3 -m unittest agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest -v
```

결과: (Exit Code: 0)
```
test_cloud_g07_provider_quota_promotes_claude_to_codex_without_no_failover_block (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_cloud_g07_provider_quota_promotes_claude_to_codex_without_no_failover_block) ... ok
test_completing_target_controls_selfcheck_and_reuses_pin (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_completing_target_controls_selfcheck_and_reuses_pin) ... ok
test_day_gemini_failure_continues_on_laguna_with_logical_context (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_day_gemini_failure_continues_on_laguna_with_logical_context) ... ok
test_generic_failure_stays_on_same_target (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_generic_failure_stays_on_same_target) ... ok
test_invalid_logical_context_does_not_commit_or_promote (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_invalid_logical_context_does_not_commit_or_promote) ... ok
test_night_gemini_quota_exhaustion_blocks_without_bounce (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_night_gemini_quota_exhaustion_blocks_without_bounce) ... ok
test_night_laguna_failure_continues_on_available_gemini (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.DispatcherCanonicalFailoverIntegrationTest.test_night_laguna_failure_continues_on_available_gemini) ... ok
test_completed_implementation_checklist_starts_review (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_completed_implementation_checklist_starts_review) ... ok
test_default_or_arbitrary_status_text_does_not_start_review (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_default_or_arbitrary_status_text_does_not_start_review) ... ok
test_exact_official_verdict_section_starts_review_recovery (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_exact_official_verdict_section_starts_review_recovery) ... ok
test_local_g07_g08_route_uses_explicit_kst_boundaries (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_local_g07_g08_route_uses_explicit_kst_boundaries) ... ok
test_local_route_grade_boundaries (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_local_route_grade_boundaries) ... ok
test_new_canonical_pi_target_gets_default_invocation_semaphore (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_new_canonical_pi_target_gets_default_invocation_semaphore) ... ok
test_only_explicit_user_review_file_stops_the_loop (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_only_explicit_user_review_file_stops_the_loop) ... ok
test_pi_worker_success_requires_selfcheck_before_review (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_pi_worker_success_requires_selfcheck_before_review) ... ok
test_selfcheck_accepts_filled_implementation_review_fields (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_selfcheck_accepts_filled_implementation_review_fields) ... ok
test_selfcheck_requires_all_implementation_review_fields (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_selfcheck_requires_all_implementation_review_fields) ... ok
test_user_review_none_values_do_not_form_a_valid_stop (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_user_review_none_values_do_not_form_a_valid_stop) ... ok
test_user_review_only_directory_without_logs_is_readable (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_user_review_only_directory_without_logs_is_readable) ... ok
test_user_review_with_active_pair_is_state_blocked (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_user_review_with_active_pair_is_state_blocked) ... ok
test_user_review_without_blocking_contract_is_state_blocked (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_user_review_without_blocking_contract_is_state_blocked) ... ok
test_verdict_text_outside_official_section_does_not_start_review (agent-ops.skills.project.orchestrate-agent-task-loop.tests.test_dispatch.TaskStageTest.test_verdict_text_outside_official_section_does_not_start_review) ... ok

----------------------------------------------------------------------
Ran 22 tests in 0.279s

OK
```

### 전체 suite 및 정적 검증

```bash
env -u IOP_FORCE_GEMINI_TODAY python3 -m unittest discover -s agent-ops/skills/project/orchestrate-agent-task-loop/tests -p 'test_*.py' -v
python3 -m py_compile agent-ops/skills/project/orchestrate-agent-task-loop/scripts/execution_target_policy.py agent-ops/skills/project/orchestrate-agent-task-loop/scripts/select_execution_target.py agent-ops/skills/project/orchestrate-agent-task-loop/scripts/dispatch.py agent-ops/skills/project/orchestrate-agent-task-loop/tests/test_execution_target_policy.py agent-ops/skills/project/orchestrate-agent-task-loop/tests/test_select_execution_target.py agent-ops/skills/project/orchestrate-agent-task-loop/tests/test_dispatch.py
! rg -n "IOP_FORCE_GEMINI_TODAY|manual-gemini-today|manual_today_gemini|worker-local-g07-g08-manual-gemini" agent-ops/skills/project/orchestrate-agent-task-loop/scripts agent-ops/skills/project/orchestrate-agent-task-loop/tests
git diff --check
```

결과: (Exit Code: 0)
- `unittest discover`: Ran 192 tests in 8.271s, OK.
- `py_compile`: Clean compilation, exit code 0.
- `rg`: No matches found (exit code 1 for raw `rg`, matching `! rg`), exit code 0.
- `git diff --check`: No whitespace errors, exit code 0.

---

> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section?**
> If anything is blank, go back and fill it in before saving this file.
> Leave review-agent-only sections unchanged.

## 섹션 소유권

| Section | Owner | Note |
|---------|-------|------|
| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute these (archive, complete.log, and task-directory archive move are review-agent only) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| Archive Evidence Snapshot | Fixed at stub creation from plan when present | Implementing agent uses it as default prior-loop context; read only the specific archive files cited there when more detail is required |
| Agent UI Completion | Mixed | Present only for plan-required agent-ui code work; implementing agent fills actual evidence, review agent applies `구현됨` status/evidence update on PASS and copies the section into `complete.log` |
| 구현 항목별 완료 여부 (item names) | Fixed at stub creation | Implementing agent checks `[ ]` → `[x]` only |
| 구현 체크리스트 (item text/order) | Fixed at stub creation from plan | Implementing agent checks `[ ]` → `[x]` only |
| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify or check this section |
| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholder text with actual content |
| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Pre-filled from plan |
| 검증 결과 (section headings + commands) | Fixed at stub creation | Implementing agent fills in command output only; command changes require a `계획 대비 변경 사항` entry |
| 코드리뷰 결과 | Review agent appends | Not included in stub |

## 코드리뷰 결과

- 종합 판정: FAIL
- Required: 2
- Suggested: 0
- Nit: 0

### 차원별 평가

| 차원 | 결과 | 근거 |
|------|------|------|
| 정확성 | Fail | 주간 initial이 quota 때문에 Laguna를 선택한 뒤 Gemini quota가 회복되면 failover가 candidate rank를 역행해 Laguna에서 Gemini로 전환한다. |
| 완전성 | Fail | S07의 재오픈 호출 횟수/target과 production 성공 reset evidence가 계획대로 닫히지 않았다. |
| 테스트 커버리지 | Fail | 192개 테스트가 통과하지만 reverse-rank failover와 production success reset을 검출하지 못한다. |
| API 계약 | Fail | selector가 canonical ordered candidate의 현재 선택 이후가 아닌 모든 미사용 후보를 다시 탐색한다. |
| 코드 품질 | Pass | 미사용 `os` import는 리뷰 중 비동작성 정리로 제거했고 별도 debug/TODO 잔여물은 발견하지 못했다. |
| 구현 편차 | Fail | S07 계획은 actual 1+9 invocation과 stage 성공 경로 reset을 요구하지만 테스트는 counter/helper만 직접 확인한다. |
| 검증 신뢰도 | Fail | 제출 명령은 재실행 시 모두 성공했으나 focused reproducer가 all-green suite 밖의 S06 위반을 확인했다. |
| 스펙 정합성 | Fail | 승인 SDD S06의 단방향 failover/no-bounce와 S07 Evidence Map의 실제 stage lifecycle 증거를 충족하지 못한다. |

### 발견된 문제

1. **Required — `agent-ops/skills/project/orchestrate-agent-task-loop/scripts/select_execution_target.py:769`**: `_failover()`가 현재 `selected`의 canonical rank를 기준으로 뒤 후보만 찾지 않고 `prior["candidates"]` 전체에서 첫 미사용 eligible 후보를 선택한다. 주간 Gemini exhausted snapshot으로 initial Laguna를 선택한 뒤 Gemini snapshot을 available로 바꾸고 Laguna의 `provider-stream-disconnect`를 전달하면 실제 출력이 Laguna→Gemini가 된다. 이는 SDD S06의 주간 Gemini→Laguna 단방향 전환과 quota 회복만으로 이전 rank에 되돌아가지 않는 계약을 위반한다. 현재 selected rank 이후의 후보만 failover 대상으로 제한하고, initial이 후순위 후보를 선택한 경우 앞 rank의 quota가 회복되어도 `no_failover_candidate`로 닫는 selector 및 dispatcher 회귀 테스트를 추가한다.
2. **Required — `agent-ops/skills/project/orchestrate-agent-task-loop/tests/test_dispatch.py:5400`**: S07 테스트는 재오픈 mock의 `call_count`와 각 호출 `AgentSpec`을 assertion하지 않아 Laguna 8회 추가 호출, 전체 Gemini 1 + Laguna 9 invocation을 직접 증명하지 않는다. `test_success_resets_only_current_stage_budget`도 `run_escalating()`의 성공 분기 대신 `StageFailureBudget.reset_on_success()`를 직접 호출해 production 경로가 worker budget만 지우고 review budget을 보존한다는 사실을 검증하지 못한다. 재오픈 호출 수·순서·최종 locator를 assertion하고, preloaded worker/review budget 상태에서 실제 worker 성공을 실행해 stage-local reset을 확인한다.

### 검증 근거

- focused selector 26 tests, S07 7 tests, S10/dispatcher 22 tests를 재실행해 모두 PASS를 확인했다.
- 전체 `unittest discover`는 192 tests를 8.869초에 완료했고 PASS했다. `py_compile`, 금지 심볼 `rg`, `git diff --check`도 성공했다.
- 별도 focused reproducer는 `initial=pi/iop/laguna-s:2.1`, 회복 snapshot 뒤 `failover=agy/Gemini 3.6 Flash (Medium)`을 출력해 reverse-rank 전환을 재현했다.

### 다음 단계

- `plan` 스킬의 `prepare-follow-up` 및 `isolated-reassessment`로 위 두 Required를 닫는 후속 PLAN/CODE_REVIEW 쌍을 생성한다.
