# BAT-017 Verification - Status: verified - Batch: BAT-017 ## Acceptance Mapping ### REQ-012 (KIS 취소 감지, change-req) | AC | Evidence | |----|----------| | cncl_yn → cancelled (체결 0) | tests/adapters/broker/test_kis_cancel.py::test_full_external_cancel_maps_to_cancelled | | 비취소 zero-fill → accepted | ::test_zero_fill_not_cancelled_stays_accepted | | 부분 체결 + 취소 → is_partial_cancel + execution_id | ::test_partial_fill_then_cancel_flags_partial_cancel | | 전량 체결 회귀 | ::test_full_fill_unaffected_by_cancel_flag | ### REQ-013 (집행 부분 체결 회계, change-req) | AC | Evidence | |----|----------| | 전량 외부 취소 → holding 복귀 + clear (영구 갇힘 0) | tests/application/test_execution_cancel.py::test_full_external_cancel_returns_slot_to_holding | | 부분 취소 → qty 차감 + holding 잔여 + cost basis 유지 | ::test_partial_fill_then_cancel_records_and_keeps_remainder | | 기존 filled/reject 회귀 | tests/application/test_execution.py 전체 | ### REQ-018 (부분 체결분 원장 1회, change-req) | AC | Evidence | |----|----------| | 부분 취소 시 sell 원장 1건(qty=체결분, price=체결가) | test_execution_cancel.py::test_partial_fill_then_cancel_records_and_keeps_remainder | ### REQ-031 (포지션 정합 연계, change-req) | AC | Evidence | |----|----------| | 부분 취소 후 slot.qty = 잔여 held (과매도 0) | test_execution_cancel.py::test_partial_fill_then_cancel_records_and_keeps_remainder (qty==6) | | reconcile 로직 불변 회귀 | tests/application/test_reconciliation.py 전체 | ### REQ-014 (pending stale 워치독 Alert-only, change-req) | AC | Evidence | |----|----------| | 임계 초과 pending → WARN + 카운터, 상태 미변경 | test_execution_cancel.py::test_stale_pending_watchdog_warns_without_state_change | | 비활성(default) → 무경고 | ::test_stale_watchdog_disabled_by_default | ### REQ-015 (baseline 문서, change-req) | AC | Evidence | |----|----------| | interface-contract/runtime-flows 정합 | 문서 diff(BAT-017) | ## Evidence - Test: - 단위 전체 회귀: `294 passed / 32 skipped`(신규 KIS 취소 4 + 집행 취소/워치독 4 포함; `::test_sandbox_token_and_submit` deselect). - 인프라 게이트(PG trex_core_test + RabbitMQ): `326 passed`. - `ruff check trex_core tests` → All checks passed. - Logs: `294 passed, 32 skipped, 1 deselected` / `326 passed, 1 deselected ~15.9s`. ## 성공 기준(dcy-013) 대응 - S-1(외부 취소 → cancelled 감지 → holding 복귀, 영구 갇힘 0): test_full_external_cancel_maps_to_cancelled + test_full_external_cancel_returns_slot_to_holding. - S-2(죽은 주문 추가 폴링 없음): 취소 감지 후 clear_dispatch 로 broker_order_id 비워져 list_dispatched_pending 에서 제외(폴링 중단) — test_full_external_cancel_returns_slot_to_holding(broker_order_id is None). - S-3(부분 체결분 원장 1회 + 잔여 정합, 과매도/이중기록 0): test_partial_fill_then_cancel_records_and_keeps_remainder(sell 1건 + qty 6 + cost basis 1000). - S-4(임계 초과 pending stale 가시화, 상태 미변경): test_stale_pending_watchdog_warns_without_state_change. ## Carried-Over / 비차단 - R-1(KIS `cncl_yn` 실제 필드/값 규약): `cncl_yn="Y"` 가정으로 구현, 실 응답 확인은 운영/검증 단계. 미지 값 보수 처리 + stale 워치독(FR-3) backstop 으로 무한 갇힘 가시화 안전망 확보. - 실 KIS 외부 취소 full-stack e2e: 실계좌 세션 필요로 이월(운영 검증, 비차단). - R-2(외부 취소→재매도 반복 루프): dcy-010 per-slot 쿨다운과 연계, cancelled 쿨다운 트리거 포함은 후속. - 워치독 auto-remediation: 후속 분리(OQ-2 Alert-only 결정). ## Result - Ready for Release: true - Blocking Issues: - 없음. 전량 취소 자동 복구·부분 체결 회계·stale 워치독 모두 단위 green(326 passed 회귀). LIVE sandbox 토큰 deselect 는 `.env` 환경 의존(본 batch 무관). KIS cncl_yn 실 규약은 운영 검증 비차단(보수 처리 + 워치독 backstop).