Files
trex-core/docs/srs/Migration/req-064_pool-to-permanent-slot-cutover.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.4 KiB

req-064: 풀 모델 → 자산 중심 DB 재초기화 (구 cutover 마이그레이션)

  • Status: Implemented
  • Type: Migration
  • Priority: High
  • Owner: project maintainers

Intent

  • 익명 풀 모델(일일 daily_slot 행) 데이터베이스를 자산 중심 영구 슬롯 substrate 로 전환한다. 데이터 보존 cutover 는 폐기(CHG-20260610-03): 마이그레이션 009 의 부분 유니크 인덱스가 legacy 풀 데이터(같은 자산이 closed+재진입 holding 으로 portfolio_id 중복)에 적용 불가한 결함 + dev/페이퍼 컨텍스트로, DB wipe + 자산 중심 재초기화로 전환한다. (dcy-020 NFR-2/R-1; 결함 출처는 실 DB 점검 2026-06-10)

Requirement

  • trex-core-reset 도구로 slot-core 테이블(daily_slot/daily_symbol_entries/slot_transition_log/intent_log/ledger_outbox/snapshot_pause/killswitch_exclusion)을 wipe 한 뒤 마이그레이션을 재적용해 DB 가 깨끗한 자산 중심 스키마(009 부분 유니크 인덱스·010 inactive CHECK·011 컬럼 drop)에 착지하게 한다. 빈 테이블에는 인덱스가 정상 생성되고, 자산 중심에서 (instance_key, portfolio_id)는 universe reconcile 가 항상 채우므로 설계상 유일하다. 파괴적·DB 전역이며 dry-run 기본 + --yes 적용, 실행 전 백업을 전제로 한다. 보유 포지션 carry-over 는 하지 않으며, 재초기화 후 universe reconcile(REQ-058) + reconcile_core_holdings(REQ-062)로 운영자가 재편입한다.

Acceptance Criteria

  1. Given 기존 풀 모델(또는 임의 상태) DB, When trex-core-reset --yes, Then slot-core 테이블이 wipe 되고 daily_slot 컬럼셋이 EXPECTED_SLOT_FIELDS(자산 중심)와 일치하며 부분 유니크 인덱스·inactive CHECK 가 존재한다.
  2. Given 재초기화 후, When 데몬 기동, Then universe reconcile(REQ-058)·admission(REQ-059)·safety-sell 이 회귀 없이 동작한다.
  3. Given 안전성, When dry-run 실행, Then 어떤 행도 변경되지 않고 wipe 대상 행수만 보고된다. 재초기화는 멱등이다(2회차도 0행·schema_ok).
  4. Given 보유 포지션, When 재초기화(데이터 보존 폐기), Then 보유는 소실되며 재초기화 후 브로커 보유가 reconcile_core_holdings(REQ-062)의 unmanaged 경로로 표면화되어 운영자가 재편입한다. 롤백 = 사전 백업 복원.

Impacted Area

  • Docs: docs/runtime-flows.md(재초기화 절차), 릴리즈 Rollback Plan(백업 복원)
  • Modules: trex_core/runtime/reset.py, trex_core/adapters/persistence/sql/(009~011)
  • Tests: tests/runtime/test_reset.py(PG-gated), 회귀 스위트

Notes

  • 라이브 데이터 영향 — 파괴적·DB 전역. 배포 게이트·운영자 입회·사전 백업 필수. 실행은 release(REL) 단계 운영자 작업으로 confirm-release 전 백업 evidence 필요.
  • 구 cutover 도구(trex-core-cutover/runtime/cutover.py)는 폐기·삭제(CHG-20260610-03).
  • 출처: dcy-020 NFR-2, R-1 + 마이그레이션 009 legacy 충돌 결함.

Change Log

CHG-20260610-01

  • Date: 2026-06-10
  • Author: Justin Ko

Change Summary

  • dcy-020 NFR-2/R-1 로부터 최초 생성(Proposed). 일일행→영구행 cutover + 보유 carry-over + instance_key 태깅 + 롤백 계획.

Intent

  • 라이브 풀 모델 데이터를 무손실로 영구 슬롯 모델로 이행하는 cutover 를 backlog 정규화.

Acceptance Criteria Delta

  • Added: 보유 carry-over/기동 회귀/롤백/instance_key 태깅 4개 기준
  • Updated: 없음
  • Removed: 없음

Impacted Area Delta

  • Docs: docs/runtime-flows.md, 릴리즈 Rollback Plan
  • Modules: persistence cutover 마이그레이션, 이행 스크립트
  • Tests: cutover round-trip, 회귀 스위트

Delivery Trace Delta

  • Batches: none
  • Releases: none

Revalidation Impact

  • Reverification Needed: yes (cutover 리허설/회귀 필수)
  • Existing Implementation Invalidated: no (이행 절차 신규)
  • Status Recommendation: keep-current
  • Follow-up Action: confirm-req. 별도 배치(BAT-δ)·운영자 입회·confirm-release 전 리허설 evidence.

Validation Plan

  • cutover 리허설(보유 보존·기동 회귀·롤백) + run-the-app evidence.

CHG-20260610-02

  • Date: 2026-06-10
  • Author: Justin Ko

Change Summary

  • Status Proposed → Approved (confirm-req). 필수 필드·구체 AC 충족, source dcy-020(confirmed, handoff 승인)과 모순 없음.

Intent

  • delivery input 으로 승격(라이브 cutover 는 별도 배치·운영자 입회).

Acceptance Criteria Delta

  • Added: 없음 / Updated: 없음 / Removed: 없음

Impacted Area Delta

  • Docs: docs/srs/index.md (Register Approved) / Modules: 없음 / Tests: 없음

Delivery Trace Delta

  • Batches: none / Releases: none

Revalidation Impact

  • Reverification Needed: no (승인 단계) / Existing Implementation Invalidated: no / Status Recommendation: keep-current / Follow-up Action: 별도 cutover 배치(BAT-δ), confirm-release 전 리허설 evidence.

Validation Plan

  • 승인 후 cutover 배치 planning 에서 본 REQ AC 를 검증 기준으로 사용.

CHG-20260610-03

  • Date: 2026-06-10
  • Author: Justin Ko

Change Summary

  • 데이터 보존 cutover → DB 재초기화로 재정의. BAT-030 구현 중 실 DB 점검에서 마이그레이션 009 부분 유니크 인덱스가 legacy 풀 중복 데이터(같은 portfolio_id 가 closed+holding 2행)에 적용 불가 → cutover·데몬 부팅 모두 차단되는 결함 확인. 사용자 결정으로 데이터 보존 마이그레이션을 폐기하고 trex-core-reset(wipe+재초기화)로 대체. 구 trex-core-cutover 도구·테스트 삭제.

Intent

  • 빈 테이블에 자산 중심 스키마를 깨끗이 착지시켜 009 결함을 코드 수정 없이 우회하고, 전환 절차를 단순화(데이터 보존 불요 — dev/페이퍼·신규 인스턴스 컨텍스트).

Acceptance Criteria Delta

  • Updated: AC-1~4 를 cutover(보유 carry-over/롤백 역마이그레이션) → 재초기화(wipe+스키마 착지/기동 회귀/dry-run·멱등/보유 재편입+백업 복원) 기준으로 재정의
  • Removed: 보유 무손실 carry-over, instance_key 태깅(전역 wipe 라 불필요), 역마이그레이션 롤백

Impacted Area Delta

  • Modules: trex_core/runtime/reset.py(신규), runtime/cutover.py(삭제)
  • Tests: tests/runtime/test_reset.py(신규), test_cutover_rehearsal.py(삭제)
  • Docs: data-model/runtime-flows/project-structure(도구 서술 교체)

Delivery Trace Delta

  • Batches: BAT-030
  • Releases: none (실 재초기화는 REL 단계)

Revalidation Impact

  • Reverification Needed: yes (reset 도구 PG 테스트로 충족)
  • Existing Implementation Invalidated: yes (cutover 도구 폐기)
  • Status Recommendation: keep-current (Implemented — reset evidence 로 대체 충족)
  • Follow-up Action: 실 DB 재초기화는 REL 단계 운영자(백업 선행).

Validation Plan

  • tests/runtime/test_reset.py(wipe+스키마 착지·dry-run·멱등·재편입 가능) + run-the-app e2e.

CHG-20260610-IMPL

  • Date: 2026-06-10
  • Author: Justin Ko
  • Type: status
  • Summary: Approved → Implemented (confirm-req-implemented), 이후 CHG-20260610-03 으로 재정의 반영. 근거: BAT-030(trex-core-reset 도구 + PG reset 테스트 5건; 실 재초기화는 REL 운영자) — 재정의 AC 가 release-candidate 배치 verification 의 evidence 와 연결됨(단위 367/PG 26/MQ 21 passed + run-the-app 자산 중심 e2e). Blocking Issues 없음.