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>
8.0 KiB
8.0 KiB
req-003: slot 도메인 단위테스트 이식 및 컬럼 계약 가드
- Status: Implemented
- Type: Testing
- Priority: High
- Owner: project maintainers
Intent
- 이식의 정확성(도메인 불변식)과
Slot컬럼 계약을 자동 테스트로 강제해, 테스트 우선 검증(Global Rule 3)을 충족하고 향후 영속화 단계의 계약 드리프트를 막는다.
Requirement
- trex-orbit 의 순수 도메인 단위테스트
test_state.py·test_service.py를tests/domain/slot/로 이식해 통과시키고, 도메인 패키지에 표준 필드 집합EXPECTED_SLOT_FIELDS를 선언한 뒤, 순수 계약 테스트test_contract.py가{f.name for f in dataclasses.fields(Slot)} == EXPECTED_SLOT_FIELDS를 단언하도록 신설한다.
Acceptance Criteria
- Given 이식한 단위테스트, When
pytest tests/domain/slot/test_state.py tests/domain/slot/test_service.py실행, Then 모두 통과한다. (FR-3, NFR-2 검증) - Given
EXPECTED_SLOT_FIELDS선언과test_contract.py, Whenpytest tests/domain/slot/test_contract.py실행, Then 통과한다. (NFR-3) - Given
Slot에 임시 필드를 추가하거나 삭제, When 계약 테스트를 실행, Then 테스트가 실패한다(음성 케이스 재현). - Given 계약 테스트, When 구현을 확인, Then 타입 단언은 하지 않고(이름/존재 중심) 타입 매핑은 dcy-001 부록 A / docs/data-model.md 문서에 둔다.
Impacted Area
- Docs: docs/data-model.md, dcy-001 부록 A (타입 매핑 계약 기준)
- Modules: trex_core/domain/slot (EXPECTED_SLOT_FIELDS 선언; 부록 A 를 가리키는 주석 포함)
- Tests: tests/domain/slot/{test_state,test_service,test_contract}.py
Notes
- NFR-2(불변식 검증)·NFR-3(컬럼 계약 강제)를 본 REQ 로 흡수. FR-3 + FR-5 통합.
- DB-side(information_schema) 드리프트 검사는 이번 범위 밖이며 영속화 REQ 로 인계한다(dcy-001 OQ-2).
- REQ-001(부트스트랩)·REQ-002(도메인 이식) 선행.
- 출처: dcy-001 FR-3, FR-5.
Change Log
CHG-20260603-01
- Date: 2026-06-03
- Author: Justin Ko
Change Summary
- dcy-001 FR-3·FR-5 로부터 최초 생성(Proposed). NFR-2 검증·NFR-3 강제를 흡수.
Intent
- 도메인 테스트 이식 green + 컬럼 계약 가드 요구사항을 backlog 로 정규화.
Acceptance Criteria Delta
- Added:
- 이식 테스트 통과, 계약 테스트 통과, 음성 케이스 실패 재현, 타입 단언 배제 4개 기준
- Updated:
- 없음
- Removed:
- 없음
Impacted Area Delta
- Docs:
- docs/data-model.md, dcy-001 부록 A
- Modules:
- trex_core/domain/slot (EXPECTED_SLOT_FIELDS)
- Tests:
- tests/domain/slot/{test_state,test_service,test_contract}.py
Delivery Trace Delta
- Batches:
- none
- Releases:
- none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: confirm-req 후 batch 편성
Validation Plan
pytest tests/domain/slotgreen + 필드 변경 시 계약 테스트 실패 재현으로 검증.
CHG-20260603-02
- Date: 2026-06-03
- Author: Justin Ko
Change Summary
- Status Proposed → Approved (confirm-req).
Intent
- 승인 게이트(필수 필드·구체 AC·blocker 없음) 충족, source dcy-001(confirmed, handoff 승인)과 모순 없음 확인.
Acceptance Criteria Delta
- Added:
- 없음
- Updated:
- 없음
- Removed:
- 없음
Impacted Area Delta
- Docs:
- docs/srs/index.md (Register 상태 Approved)
- Modules:
- 없음
- Tests:
- 없음
Delivery Trace Delta
- Batches:
- none (batch 편성 전)
- Releases:
- none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: suggest-batch-reqs / draft-batch 로 delivery batch 편성
Validation Plan
- 승인 후 batch planning 에서 본 REQ 의 Acceptance Criteria 를 검증 기준으로 사용.
CHG-20260603-03
- Date: 2026-06-03
- Author: Justin Ko
Change Summary
- Status Approved → Implemented (confirm-req-implemented, 근거 batch BAT-001 release-candidate).
Intent
- BAT-001 verification.md 의 evidence(이식 테스트 green / 계약 테스트 green / rogue 필드 음성 케이스 / 타입 단언 배제)로 AC1~AC4 충족 → 구현 완료 동기화.
Acceptance Criteria Delta
- Added:
- 없음
- Updated:
- 없음
- Removed:
- 없음
Impacted Area Delta
- Docs:
- docs/srs/index.md (Register Implemented)
- Modules:
- 없음
- Tests:
- 없음
Delivery Trace Delta
- Batches:
- BAT-001 (release-candidate)
- Releases:
- none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: draft-release 로 release 편성
Validation Plan
- BAT-001 verification evidence 재참조로 충분.
CHG-20260608-01
- Date: 2026-06-08
- Author: Justin Ko
Change Summary
- (change-req, dcy-012) 컬럼 계약 가드를
entry_price→limit_pricerename 에 맞춰 갱신.EXPECTED_SLOT_FIELDS(REQ-002)와 daily_slot 실제 컬럼(information_schema) 대조가limit_price기준으로 통과. BAT-016 재구현·재검증 완료 → Implemented 유지.
Intent
- 도메인/스키마 rename 후에도 코드 계약 ↔ DB 컬럼 드리프트 가드가 정확히 작동하도록 동기화.
Acceptance Criteria Delta
- Updated:
- 컬럼 계약/드리프트 테스트 기준 필드 entry_price → limit_price.
Impacted Area Delta
- Tests: tests/domain/slot/test_contract.py, tests/adapters/persistence/test_migration_and_drift.py
- Modules: (없음 — 가드는 EXPECTED_SLOT_FIELDS 상수 참조)
Delivery Trace Delta
- Batches: BAT-016
- Releases: none
Revalidation Impact
- Reverification Needed: yes (BAT-016 에서 완료)
- Existing Implementation Invalidated: no (가드 로직 불변, 기대 필드셋만 rename 반영)
- Status Recommendation: Implemented (change-req → BAT-016 재검증)
- Follow-up Action: confirm-req-implemented(BAT-016).
Validation Plan
- BAT-016: 도메인 필드셋 가드 + PG 컬럼 드리프트 가드 green.
CHG-20260609-01
- Date: 2026-06-09
- Author: Justin Ko
Change Summary
- (change-req, dcy-019/issue #18) 슬롯 도메인 변경(REQ-002: entry_count 필드 + closed→pending_buy 전이)에 맞춰 테스트 계약 정합: 상태 머신 전이 카운트 14→15(
closed→pending_buyallowed 이동), 컬럼 계약 가드가entry_count를 포함, entry_count 증분·보존/closed 재할당 selector 단위 테스트(test_slot_entry_count.py) 추가. BAT-025 검증 완료 → Implemented 유지.
Intent
- entry_count + closed 재할당 도메인 변경이 회귀 없이 계약(필드셋·전이 집합)으로 강제되도록 테스트를 동기화.
Acceptance Criteria Delta
- Updated:
- 상태 머신 전이 집합 테스트:
closed→pending_buy를 allowed 로, ALLOWED_TRANSITIONS 크기 14→15 로 단언. - 컬럼 계약 가드:
EXPECTED_SLOT_FIELDS에entry_count포함을 검증.
- 상태 머신 전이 집합 테스트:
- Added:
- entry_count 증분/보존, closed→pending_buy clean-slate, find_allocatable_slot 정렬 단위 테스트.
Impacted Area Delta
- Tests: tests/domain/slot/test_state.py, tests/domain/slot/test_contract.py, tests/domain/slot/test_slot_entry_count.py(신규), tests/application/test_buy_admission_reallocation.py(신규), tests/adapters/persistence/test_migration_and_drift.py(EXPECTED_SLOT_FIELDS 자동 반영)
Delivery Trace Delta
- Batches: BAT-025
- Releases: none
Revalidation Impact
- Reverification Needed: yes (BAT-025 에서 완료)
- Existing Implementation Invalidated: no (계약 테스트 확장 — 기존 단언 보존)
- Status Recommendation: Implemented (change-req → BAT-025 재검증)
- Follow-up Action: confirm-req-implemented(BAT-025).
Validation Plan
- BAT-025: 전이/계약 가드 + 신규 entry_count·reallocation 단위 테스트 green (unit), PG 게이트 드리프트 가드는 test DSN 환경에서 자동 검증.