feat(slot): slot entry_count + closed-slot reallocation (dcy-019, BAT-025) + REL-005
dcy-019/issue #18: slot 자원을 진입 횟수 기준으로 고르게 재사용하고 idle 소진 시 closed 슬롯을 직접 재할당한다. 거버넌스는 전부 change-req(신규 REQ 없음). - 도메인(REQ-002): Slot.entry_count(기본 0) + EXPECTED_SLOT_FIELDS, 상태 머신 closed→pending_buy 신규 전이(base 8→9, ALLOWED_TRANSITIONS 14→15), _apply_transition_fields closed→pending_buy clean-slate + →pending_buy 시 +1 - 영속화(REQ-006): 멱등 마이그레이션 008(entry_count), flat 매핑, find_allocatable_slot(idle∪closed, entry_count→updated_at→slot_id) + in-memory 동등 - admission(REQ-007): _admit_buy find_idle_slot→find_allocatable_slot + from_state=slot.status - 테스트(REQ-003): 전이 카운트/계약 가드 정합 + test_slot_entry_count.py / test_buy_admission_reallocation.py - 문서(REQ-009): data-model.md / runtime-flows.md 정합 - 기존 daily_symbol_entries(symbol-scoped) 분리·미변경 BAT-025(release-candidate) delivery + change-req REQ-002/003/006/007/009(CHG-20260609-01). REL-005(confirmed, app-service): BAT-024+BAT-025 묶음. operator-facing run-the-app 스모크로 enter --forced-close-at(BAT-024)·closed 재할당(BAT-025) 실 데몬 검증 (실 PG 마이그레이션 008 round-trip 포함). 검증: 단위 366 passed / 35 skipped(KIS sandbox 1건 deselect — live .env 환경 의존), ruff clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -191,3 +191,44 @@
|
||||
#### Validation Plan
|
||||
|
||||
- BAT-016: PG 게이트 마이그레이션 round-trip + 컬럼 계약(limit_price) + idempotency.
|
||||
|
||||
### CHG-20260609-01
|
||||
|
||||
- Date: 2026-06-09
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
|
||||
- (change-req, dcy-019/issue #18) 영속화 레이어에 slot-scoped `entry_count` 반영: 멱등 마이그레이션 008(`ALTER TABLE daily_slot ADD COLUMN IF NOT EXISTS entry_count INTEGER NOT NULL DEFAULT 0`), `_SLOT_COLUMNS`/`update_slot`/`_row_to_slot` flat 매핑 +entry_count, 신규 `find_allocatable_slot`(idle ∪ closed, `ORDER BY entry_count ASC, updated_at ASC, slot_id ASC LIMIT 1`) selector 추가(in-memory 동등 구현 포함). 동시성은 기존 advisory lock + 재시도 규약 보존(find 쿼리 FOR UPDATE 미사용 — find_idle_slot 와 동일). BAT-025 검증 완료 → Implemented 유지.
|
||||
|
||||
#### Intent
|
||||
|
||||
- buy admission 의 후보 확장(idle∪closed)·공정 정렬을 영속 store 에서 결정적으로 지원하고, slot row 에 진입 횟수를 durable 하게 보존.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
|
||||
- Updated:
|
||||
- AC-1 컬럼 계약: `daily_slot` 에 `entry_count` 컬럼 추가(마이그레이션 008, additive·멱등). `EXPECTED_SLOT_FIELDS` ↔ information_schema 드리프트 가드가 자동 반영.
|
||||
- Added:
|
||||
- `find_allocatable_slot(trading_date)` 가 idle ∪ closed 후보를 `entry_count → updated_at → slot_id` 정렬로 1건 반환(없으면 None).
|
||||
|
||||
#### Impacted Area Delta
|
||||
|
||||
- Modules: `trex_core/adapters/persistence/sql/008_add_slot_entry_count.sql`(신규), `trex_core/adapters/persistence/postgresql.py`(_SLOT_COLUMNS/update_slot/_row_to_slot/find_allocatable_slot), `trex_core/domain/slot/repository.py`·`in_memory_repository.py`(selector 포트 + 동등 구현)
|
||||
- Tests: tests/adapters/persistence/test_migration_and_drift.py(자동 반영), tests/domain/slot/test_slot_entry_count.py(selector 정렬)
|
||||
|
||||
#### Delivery Trace Delta
|
||||
|
||||
- Batches: BAT-025
|
||||
- Releases: none
|
||||
|
||||
#### Revalidation Impact
|
||||
|
||||
- Reverification Needed: yes (BAT-025 에서 완료)
|
||||
- Existing Implementation Invalidated: no (additive 컬럼·신규 selector — 기존 find_idle_slot/round-trip 보존)
|
||||
- Status Recommendation: Implemented (change-req → BAT-025 재검증)
|
||||
- Follow-up Action: confirm-req-implemented(BAT-025).
|
||||
|
||||
#### Validation Plan
|
||||
|
||||
- BAT-025: unit (in-memory selector 정렬·reallocation) green; 마이그레이션 008 round-trip + 드리프트 가드는 test DSN 환경에서 자동 검증(라이브 runtime DSN 미사용 — 파괴적 truncate 회피).
|
||||
|
||||
Reference in New Issue
Block a user