feat(slot): BAT-027 M1 — additive 영구 슬롯 필드(instance_key, retired_at) + 마이그레이션 009 (dcy-020/REQ-056)

안 B(점진/additive-first)의 1단계. 라이브 영향·cascade 없이 자산 영구 슬롯 토대의
스키마/모델 필드만 additive 추가.

- Slot.instance_key(기본 "default")·retired_at 추가 + EXPECTED_SLOT_FIELDS 정합
- 마이그레이션 009: instance_key NOT NULL DEFAULT 'default', retired_at,
  부분 UNIQUE(instance_key, portfolio_id) WHERE portfolio_id IS NOT NULL (멱등)
- postgresql _SLOT_COLUMNS/_row_to_slot/update_slot 매핑(row[19]/[20])
- entry_count/trading_date 컬럼은 유지(drop 은 cutover BAT-δ)

검증: 전체 375 passed / 35 skipped, ruff clean (additive — cascade 무파손).
M2(상태머신 inactive 별칭+인스턴스 lock)/M3(소비처 cascade)는 후속.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 10:42:24 +09:00
co-authored by Claude Opus 4.8
parent 4e92134c28
commit 86c892aa0c
4 changed files with 46 additions and 8 deletions
@@ -0,0 +1,16 @@
-- BAT-027 / dcy-020 / REQ-056 (안 B): asset-centric permanent slot foundation.
-- Additive step — adds the instance scope key and the soft-retire marker without
-- touching live rows or dropping pool-model columns (entry_count/trading_date
-- removal is deferred to the cutover, BAT-δ).
-- * instance_key: scopes slots per daemon instance in a shared DB. DEFAULT
-- 'default' keeps existing single-instance rows valid; real tagging happens
-- in the cutover (REQ-064).
-- * retired_at: soft-retire / universe-detached marker (OQ-2).
-- Uniqueness is a PARTIAL index (WHERE portfolio_id IS NOT NULL) so anonymous
-- pool rows (portfolio_id NULL) don't collide during the transition; promoted to
-- a full unique constraint after cutover.
ALTER TABLE daily_slot ADD COLUMN IF NOT EXISTS instance_key TEXT NOT NULL DEFAULT 'default';
ALTER TABLE daily_slot ADD COLUMN IF NOT EXISTS retired_at TIMESTAMPTZ;
CREATE UNIQUE INDEX IF NOT EXISTS uq_daily_slot_instance_portfolio
ON daily_slot (instance_key, portfolio_id)
WHERE portfolio_id IS NOT NULL;