Files
trex-core/docs/batches/bat-030_20260610_asset-centric-cutover/verification.md
T
genichinandClaude Opus 4.8 c04fd276b3 feat(reset): cutover 도구 폐기 → trex-core-reset(DB 재초기화) 대체 (REQ-064 CHG-20260610-03)
실 DB 점검 중 마이그레이션 009 부분 유니크 인덱스가 legacy 풀 데이터(같은
자산이 closed+재진입 holding 으로 portfolio_id 중복)에 적용 불가 → cutover·
데몬 부팅 모두 차단되는 결함 확인. 데이터 보존 cutover 를 폐기하고 DB wipe +
자산 중심 재초기화로 전환(사용자 결정). 빈 테이블에는 009 인덱스가 정상
생성되고 자산 중심에서 (instance_key, portfolio_id)는 설계상 유일.

- trex_core/runtime/reset.py 신규(trex-core-reset): slot-core 7테이블 wipe +
  apply_migrations 재적용 → 자산 중심 스키마 착지 검증. dry-run 기본/--yes 적용,
  파괴적·DB 전역. 보유 carry-over 없음(재초기화 후 reconcile_core_holdings 재편입).
- runtime/cutover.py + trex-core-cutover console script + test_cutover_rehearsal.py 삭제.
- pyproject: trex-core-reset 등록.
- tests/runtime/test_reset.py 신규 5건(PG-gated): wipe+착지·dry-run 무변경·멱등·
  wipe 후 admission·테이블 커버리지.
- change-req REQ-064 CHG-20260610-03(cutover→재초기화 재정의) + srs index 갱신.
- baseline 4문서(data-model/runtime-flows/project-structure/interface-contract)
  + BAT-030 design/planning/index/implementation/verification 도구 서술 reset 으로 교체.

검증: ruff clean, 단위 367 passed, PG+RabbitMQ 통합 411 passed/1 skip(KIS sandbox).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 16:08:05 +09:00

7.6 KiB
Raw Blame History

BAT-030 Verification

  • Status: approved (confirm-batch-verification, 2026-06-10)
  • Batch: BAT-030
  • 일자: 2026-06-10
  • 검증 환경: Python 3.12 / PostgreSQL trex_core_test(실 DB) / 실 RabbitMQ / paper broker

Acceptance Mapping

REQ-056 (Data — 잔여: trading_date/entry_count drop, 스키마 마감)

AC 판정 Evidence
AC-1 스키마: portfolio_id·instance_key·부분 UNIQUE(instance_key,portfolio_id)·retired_at·trading_date/entry_count 부재 pass 마이그레이션 009/010/011 + test_daily_slot_columns_match_expected_contract(drop 후 컬럼셋 == EXPECTED_SLOT_FIELDS) + test_reset_wipes_and_lands_asset_centric(유니크 인덱스·inactive CHECK 존재 확인). ※ portfolio_id NOT NULL 승격은 데이터 보존 cutover 와 함께 폐기 — 자산 중심에서 universe reconcile 이 항상 portfolio_id 를 채우므로 부분 유니크로 충분(CHG-20260610-03)
AC-2 EXPECTED_SLOT_FIELDS ↔ information_schema 일치 pass tests/adapters/persistence/test_migration_and_drift.py 3건 PG 통과
AC-3 (instance_key, portfolio_id) 중복 거부 pass partial UNIQUE(009) + test_universe_reconcile_pg(ON CONFLICT 멱등, created=0)
AC-4 인스턴스 간 행 미혼합 pass test_dispatch_queue_instance_scoped(집행 큐 격리) + test_instance_isolation(reconcile)

REQ-057 (Interface — 잔여: literal inactive + 별칭 제거)

AC 판정 Evidence
AC-1 허용 전이 집합 정확 일치(12종) pass tests/domain/slot/test_state.py(5 members·alias ValueError·allowed/disallowed 파라미터라이즈·set size 12)
AC-2 매도 체결 → inactive 복귀(closed 없음)·점유 clear pass test_sell_fill_returns_to_inactive_and_clears_position, test_full_lifecycle_returns_to_inactive_and_reuses(PG), e2e 7단계(status=inactive, qty=None)
AC-3 인스턴스별 락 비차단 pass slot_advisory_lock_id 인스턴스 해시(BAT-027) + test_slot_advisory_lock_id_is_instance_scoped
AC-4 동일 슬롯 동시 전이 직렬화 pass TestAdvisoryLockSerialization(1 success/1 mismatch)

REQ-062 (Integration — 잔여: M2(b) 매도 수량 브로커 정본)

AC 판정 Evidence
AC-1 매도 수량 = 브로커 잔고(미러 stale 무관) pass test_sell_qty_is_broker_balance_not_slot_mirror(미러 7 vs 브로커 10 → 주문 10) + test_sell_skipped_when_broker_flat(브로커 0 → skip+카운터, 주문 0) + test_skipped_sell_does_not_block_other_dispatches
AC-2 core holding/브로커 0 → error 격리 pass (BAT-029 기구현) tests/application/test_holding_divergence.py::test_A_* — 본 배치에서 회귀 green 재확인
AC-3 core flat/브로커 보유 → WARN·운영자 결정 pass (BAT-029 기구현; 슬롯 부재로 '격리' 대신 unmanaged WARN — issue #15 무자동조치 결정) test_B_broker_holds_unmanaged_warns
AC-4 수량 불일치 → 상태 전이 없음·warning 노출 pass (BAT-029 기구현; 미러 자동 갱신 없이 WARN — 보수 구현) test_C_qty_mismatch_warns_no_state_change

REQ-064 (Migration → DB 재초기화로 재정의, CHG-20260610-03)

원 AC(데이터 보존 cutover)는 마이그레이션 009 부분 유니크 인덱스가 legacy 풀 중복 데이터에 적용 불가한 결함으로 폐기되고, wipe + 자산 중심 재초기화(trex-core-reset)로 재정의됨. 재정의된 AC 로 매핑:

AC(재정의) 판정 Evidence
AC-1' 재초기화 시 slot-core 테이블 wipe + 자산 중심 스키마 착지 pass test_reset_wipes_and_lands_asset_centric(2행 → 0행, 컬럼==EXPECTED, 유니크 인덱스+inactive CHECK 존재)
AC-2' 재초기화 후 데몬 회귀 없음(reconcile·admission) pass test_reset_usable_for_admission_after_wipe(reset 후 reconcile+활성 동작) + run-the-app e2e(아래)
AC-3' 안전성: dry-run 무변경 + 멱등 pass test_dry_run_reports_without_wiping(행 보존) + test_reset_is_idempotent(2회차 0행·schema_ok)
AC-4' 데이터 보존(보유 carry-over) 폐기 — 보유는 reconcile 로 재편입 pass(의도된 범위 축소) CHG-20260610-03; 재초기화 후 브로커 보유는 reconcile_core_holdings(REQ-062) unmanaged 경로
(참고) 백업/복원 운영 절차 reset 은 재초기화라 롤백 = 백업 복원. 실행 전 백업 필수(release 게이트)

REQ-065 (Documentation — baseline 마감)

AC 판정 Evidence
AC-1 data-model.md 코드 일치 pass commit 7d72782 — 영구 슬롯 스키마·5-state·trading_date 강등(전이 로그/원장으로)·INACTIVE 리셋 규칙 반영
AC-2 runtime-flows.md 일치 + preallocation 서술 제거 pass 데몬 7스레드·universe reconcile 흐름(preallocation 대체)·admission slot_id·매도 브로커 정본·transit 12전이 갱신
AC-3 폐기 범위 명시(dcy-001/014/019·daily_symbol_entries) pass data-model Model Summary/Gaps + Change Log; project-structure·interface-contract 도 동기화(추가)

Evidence

  1. 단위 회귀: pytest tests → 367 passed, ruff All checks passed (commit 7d72782 시점).
  2. PG-gated(실 PostgreSQL trex_core_test): 26 passed — 마이그레이션 001~011 전체 재적용 멱등(test_apply_migrations_is_idempotent; 010 CHECK drop-and-add·011 DROP IF EXISTS·008 no-op 가 매 boot 재실행에 안전함을 모든 PG 테스트의 pg_clean 반복 적용으로 입증), 컬럼 드리프트 가드, reconcile/admission/lifecycle, dispatch 인스턴스 격리, ops_checks(transition_log 기반) 3건, reset 5건(wipe+자산 중심 착지·dry-run 무변경·멱등·wipe 후 admission·테이블 커버리지).
  3. RabbitMQ-gated(실 브로커): 21 passed — slot_id 계약 포함 intent RPC e2e dedup.
  4. run-the-app e2e(test DB + 실 RabbitMQ + paper broker, instance=e2etest, M=1): boot reconcile created=2 → snapshot(slots=2 inactive, available=1) → buy by slot_id admitted → 중복 intent identical → 2번째 자산 capacity_full → fill→holding(available=0) → 동일 슬롯 already_active → sell→fill→inactive(qty=None·portfolio_id 보존·available=1) → 동일 영구 슬롯 재매수 admitted. DB 최종행·transition_log·ledger_outbox(completed×3) 일치, 데몬 로그 ERROR/Traceback 0, SIGTERM Normal shutdown. (전 과정 implementation.md 검증 실행 절 기록)
  5. baseline 동기화(Architecture Impact 有): data-model/runtime-flows/project-structure/interface-contract 4문서 + run-trex-core-daemon 스킬 + instance.example.toml 갱신 — commit 7d72782 포함.

Blocking Issues

  • 없음 (코드/테스트 범위). 단, 실 운영 DB 재초기화는 본 배치 산출물 범위 밖 — release(REL) 단계에서 운영자가 백업→trex-core-reset --config <instance> --yes→운영 TOML max_active_slots 설정 순으로 수행하고, 그 운영 증거는 release 검증에 귀속된다. 데이터 보존 cutover 폐기로 기존 보유는 재초기화 후 운영자가 재편입한다(REQ-062 경로).

Result

  • 포함 REQ AC 전 항목 evidence 연결 완료. REQ-064 는 데이터 보존 cutover → DB 재초기화로 재정의(CHG-20260610-03, 마이그레이션 009 결함 + dev/페이퍼 컨텍스트)되어 재정의 AC 로 검증. REQ-062 AC-3/4 는 issue #15 무자동조치 결정에 따른 보수 구현(의도된 편차).
  • Ready for Release: true (배치 산출물 기준 — 코드·마이그레이션·reset 도구·테스트·baseline. 실 DB 재초기화 실행은 REL 단계 운영자 작업으로 release 게이트에 위임)