매도(sell) 주문이 현재가가 아닌 매수가(entry_price) 지정가로 나가던 버그(issue #10) 정정. 슬롯의 매수 전용 entry_price 를 side 무관 "현재 pending 주문 지정가" limit_price 로 내부 rename 하고, pending 이탈(→holding/→closed) 시 clear 해 매수 지정가가 매도로 누수되는 경로를 구조적으로 제거. 거버넌스: 전부 change-req (신규 REQ 없음, dcy-012 OQ-3). - REQ-002: Slot entry_price→limit_price rename + clear-on-exit 생애주기 - REQ-006: daily_slot 컬럼 rename 마이그레이션 006 (idempotent) + persistence 매핑 - REQ-013: _dispatch 가 slot.limit_price 단일 필드로 가격/주문유형 결정 - REQ-007: SellIntent/sell payload optional limit_price + _admit_sell 운반 - REQ-036: SlotService.sell optional 가격 → 자율 매도(safety-sell/kill-switch) 시장가 - REQ-003: 컬럼 계약/드리프트 가드 limit_price 반영 - REQ-015: runtime-flows/interface-contract/data-model 정합 매도 정책(OQ-1 하이브리드): 가격 지정→지정가("00"), 미지정→시장가("01"). 자율 매도는 가격 미전달 → 항상 시장가 (손절 미체결 pending_sell 갇힘 방지, issue #9 연계). 검증: 단위 286 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 318 passed, ruff clean. 신규 test_sell_pricing(recording broker)로 지정가 매수 슬롯의 매도가 매수가 재사용 안 함을 직접 검증. BAT-016 release-candidate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6.2 KiB
6.2 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.