REQ-058(universe reconcile)+REQ-059(자산 admission FCFS/M)+REQ-060(max_active_slots). design 확정(사용자 결정): - D1: config 게이트 이중경로 (max_active_slots 설정 시 자산중심, 미설정 시 legacy pool; 운영 데몬은 cutover 전까지 pool 무중단) - D2: "활성"(M 캡) = holding+pending_buy+pending_sell - D3: 대량소멸 가드 = N→0 + 급감(50%↓) 경고 batches/index BAT-028(standard, planning) 등록. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3.7 KiB
3.7 KiB
BAT-028 Planning
- Status: confirmed
- Batch: BAT-028
- Profile: standard
Included REQ
- REQ-060 (Configuration, Approved):
max_active_slotsper-instance TOML — 자산 중심 모드 게이트 + M 값. - REQ-058 (Integration, Approved): universe reconcile lifecycle(생성/soft-retire/tombstone, degrade 보류).
- REQ-059 (Interface, Approved): 자산 중심 admission(FCFS·M캡·무치환·over-cap·already_active).
Delivery Plan
- REQ-060:
DaemonInstanceConfig.max_active_slots: Optional[int](config/*.toml). 설정 시 자산 중심 모드, 미설정 시 legacy pool.instance.example.toml/config/.env.example주석. - REQ-058:
SlotRepository.reconcile_universe(instance_key, trading_date, universe_portfolio_ids)+ in-memory/PG 구현 — 신규 portfolio_id → 자산 슬롯 생성(멱등, inactive, portfolio_id NOT NULL), universe 에서 빠진 비활성 → retired_at set, 보유/pending → tombstone(retired_at 보류). degrade/대량소멸(N→0) 가드는 호출측(scheduler).SnapshotScheduler.run_once의 swap 직후 reconcile 훅(자산 중심 모드일 때만). - REQ-059:
IntentService._admit_buy자산 중심 분기 — 자산 중심 모드면find_slot_by_portfolio(instance_key, trading_date, portfolio_id)로 그 자산 슬롯을 잡아 활성화, 활성(holding+pending) 수 < M 이면 inactive→pending_buy, ==M 이면capacity_full, 이미 활성이면already_active. 무치환·over-cap(신규만 차단). legacy 모드면 기존 find_allocatable_slot 경로 유지. - daemon 배선: 자산 중심 모드면 preallocation 스레드 대신 reconcile(스냅샷 경로), admission 모드 플래그 전달.
- runtime-flows.md 부분 갱신(reconcile/admission 흐름, 모드 게이트).
- 단위(reconcile/admission/capacity/over-cap) + 회귀 + ruff (+ test DSN reconcile).
Dependencies
- Internal: BAT-027(영구 슬롯 스키마·instance_key·inactive 상태머신·인스턴스 lock) 선행 완료. dcy-005/BAT-008 SnapshotScheduler·universe read. dcy-014/BAT-018 preallocation(legacy 유지).
- External: portfolio-hub universe(get_portfolios) — 이미 동작.
Design Gate
- Design Required Before Implementation: yes
- Reason: (a) admission·슬롯 생성은 라이브 데몬 동작 변경이라, 자산 중심 신규 경로와 legacy pool 경로의 게이트 경계(config 기준)를 설계에서 확정해 운영 무중단을 보장해야 한다. (b) reconcile 의 tombstone/soft-retire 가 보유 포지션·safety-sell 와 얽히므로 repo 계약·degrade 가드를 못박아야 안전. (c) M 캡 카운팅(활성=holding+pending)·over-cap·동시성(인스턴스 lock)·already_active 규칙을 admission 분기에서 정확히. → design.md 확정 후 구현 전 사용자 체크포인트.
Milestones
- M1 — REQ-060 config(게이트) + 단위
- M2 — REQ-058 reconcile(repo + scheduler 훅) + 단위/ PG
- M3 — REQ-059 admission 자산 중심 분기 + capacity/over-cap 단위
- M4 — daemon 배선(모드) + runtime-flows 부분 + 회귀/ruff
Risks
- R-mode (High): legacy/자산 중심 이중 경로 혼선·라이브 회귀. 대응: config 게이트 단일 신호(max_active_slots), 기본 legacy, 신규 경로 테스트 격리.
- R-reconcile (Medium): tombstone/soft-retire 오판으로 보유 포지션 은퇴. 대응: 보유/pending tombstone·degrade 보류·대량소멸 가드, 회귀 테스트.
- R-capacity (Medium): M 캡 동시성 경합으로 초과 활성. 대응: 인스턴스 스코프 lock + 재시도, 경합 테스트.
Notes
- 라이브 데몬은 cutover(BAT-δ) 전까지 legacy pool 모드 유지(무중단). 자산 중심 default 전환은 BAT-δ.
- 본 배치 green 기준: 단위 전체 회귀(legacy 경로 무파손) + 신규 자산 중심 단위 + test DSN reconcile.