# BAT-028 Planning - Status: confirmed - Batch: BAT-028 - Profile: standard ## Included REQ - REQ-060 (Configuration, Approved): `max_active_slots` per-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 1. REQ-060: `DaemonInstanceConfig.max_active_slots: Optional[int]`(config/*.toml). 설정 시 자산 중심 모드, 미설정 시 legacy pool. `instance.example.toml`/`config/.env.example` 주석. 2. 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 훅(자산 중심 모드일 때만). 3. 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 경로 유지. 4. daemon 배선: 자산 중심 모드면 preallocation 스레드 대신 reconcile(스냅샷 경로), admission 모드 플래그 전달. 5. runtime-flows.md 부분 갱신(reconcile/admission 흐름, 모드 게이트). 6. 단위(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 1. M1 — REQ-060 config(게이트) + 단위 2. M2 — REQ-058 reconcile(repo + scheduler 훅) + 단위/ PG 3. M3 — REQ-059 admission 자산 중심 분기 + capacity/over-cap 단위 4. 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.