# BAT-023 Verification - Status: verified - Batch: BAT-023 ## Acceptance Mapping ### REQ-017 (응답 계약 확장, change-req) | AC | Evidence | |----|----------| | record_trade → LedgerWriteOutcome + `*_after`(new) | tests/adapters/ledger/test_portfolio_hub_ledger.py::test_outcome_parses_cash_quantity_after_on_new | | duplicate `*_after` | ::test_outcome_parses_after_on_duplicate | | 응답 누락 → None | ::test_outcome_after_none_when_response_omits | | 409/404/422 예외 회귀 | ::test_409_surfaces_as_ledger_conflict_error / ::test_client_errors_are_permanent | ### REQ-019 (write-back + pending_cash_delta, change-req) | AC | Evidence | |----|----------| | new write-back | tests/application/test_ledger_option_d.py::test_writeback_updates_snapshot_on_new | | duplicate write-back(멱등) | ::test_writeback_applies_on_duplicate_too | | `*_after` 누락 시 skip | ::test_writeback_skipped_when_after_missing | | best-effort(store 예외 무차단) | ::test_writeback_best_effort_does_not_block_completion | | store 미주입 무크래시 | ::test_no_writeback_without_store | | pending_cash_delta 합(InMemory/PG) | ::test_pending_cash_delta_sums_by_asset / test_postgresql_ledger_outbox.py::test_pending_cash_delta_on_pg | ### REQ-029 (추정 오버레이 + 슬롯 오버레이 유지, change-req) | AC | Evidence | |----|----------| | 미정산 자산 추정 cash + cash_estimated | tests/application/test_ledger_option_d.py::test_apply_cash_estimate_overlays_pending_delta | | write-back 후 수렴(추정 제거) | ::test_estimate_clears_after_writeback | | 슬롯 오버레이 불변 회귀 | tests/application/test_messaging_snapshot_consumer.py 전체 | ### REQ-030 (option D Approved→Implemented, change-req) | AC | Evidence | |----|----------| | AC-2/AC-3 deferred 해소(ledger write `*_after` → SnapshotStore) | test_ledger_option_d.py(write-back 전반) + REQ-017/019 evidence | | AC-1 baseline 스케줄러 회귀 | tests/application/test_preallocation_scheduler.py + snapshot scheduler 회귀 | ## Evidence - Test: - 단위 전체 회귀: `350 passed / 35 skipped`(신규 option D 11 + adapter 3 포함; `::test_sandbox_token_and_submit` deselect). - 인프라 게이트(PG trex_core_test + RabbitMQ): `385 passed`(pending_cash_delta SQL 포함). - `ruff check trex_core tests` → All checks passed. - Logs: `350 passed, 35 skipped, 1 deselected` / `385 passed, 1 deselected ~17.9s`. ## 성공 기준(dcy-018) 대응 - S-1(매수/매도 후 cash+quantity 모두 권위값 갱신): test_writeback_updates_snapshot_on_new(+duplicate). 수량은 슬롯 오버레이(유지) + write-back base 신선화. - S-2(portfolio-hub 응답 누락/불가 시 skip + ledger 정상): test_writeback_skipped_when_after_missing + test_writeback_best_effort_does_not_block_completion. - S-3(DUPLICATE 중복 적용 없음): test_writeback_applies_on_duplicate_too(절대 권위값 멱등). - (OQ-4) 추정 현금: test_apply_cash_estimate_overlays_pending_delta + test_estimate_clears_after_writeback. ## Carried-Over / 비차단 - 실 데몬 + portfolio-hub#8 full-stack option D e2e(실 `*_after` 응답 → 스냅샷 갱신)는 운영 배포 검증(REL-005 등)에서 확인 — 단위는 InMemoryLedger `*_after` 주입 + adapter 파싱으로 커버. - 추정 현금은 코어 근사 수수료 기반 — "추정/미정산" 라벨로 커버, write-back 수렴(짧은 구간). ## Result - Ready for Release: true - Blocking Issues: - 없음. option D write-back·추정 오버레이·REQ-030 전환 모두 단위 green(385 passed 회귀, record_trade 반환 타입 변경 호출부 전환 무누락). LIVE/실 portfolio-hub#8 full-stack 은 운영 배포 검증 비차단.