# BAT-027 Implementation - Status: in-progress (M1 완료, M2/M3 대기) - Batch: BAT-027 ## 구현 요약 - 안 B(점진/additive-first). M1(REQ-056 additive 모델+마이그레이션+persistence) 완료. M2/M3(상태머신 inactive 별칭 + 인스턴스 스코프 lock + 소비처 cascade)는 다음 단계. ## 변경 내역 ### M1 — REQ-056 additive (완료) - `trex_core/domain/slot/models.py`: `Slot` 에 `instance_key: str = "default"`·`retired_at: Optional[datetime] = None` 추가, `EXPECTED_SLOT_FIELDS` +instance_key/+retired_at. (entry_count/trading_date 는 안 B로 유지 — drop 은 BAT-δ) - `trex_core/adapters/persistence/sql/009_add_slot_instance_key_and_retired_at.sql`(신규): instance_key NOT NULL DEFAULT 'default', retired_at, 부분 UNIQUE(instance_key, portfolio_id) WHERE portfolio_id IS NOT NULL. additive·멱등. - `trex_core/adapters/persistence/postgresql.py`: `_SLOT_COLUMNS` +instance_key/retired_at(row[19]/[20]), `_row_to_slot` 매핑, `update_slot` SET. pre_allocate INSERT 는 DEFAULT 의존(변경 없음). ### M2 — REQ-057 상태머신+인스턴스 lock (대기) - state.py inactive 표준 + idle/closed 별칭(closed→idle 제거), advisory lock 인스턴스 스코프(2-int). ### M3 — 소비처 cascade 정합 (대기) - execution/intents/cli/ops_checks/service 등 idle·closed·전역 lock 참조 정합. ## 테스트 - M1: 도메인 슬롯 단위 79 + 전체 375 passed / 35 skipped, ruff clean(additive 무파손). PG 마이그레이션 009 round-trip 은 verification 단계에서 test DSN 검증. ## 검증 실행 - M1: `TREX_BROKER=paper pytest -q` → 375 passed / 35 skipped / 1 deselected. `ruff check trex_core` All passed.