BAT-032 (dcy-022): timeout_sec/slippage_pct 실행 정책, 미체결 자동 취소, 보호 지정가, `trex-core cancel` 백스톱. 마이그레이션 012. BAT-033: `trex-core enter --qty` 필수 검증 — 미지정 시 RPC 전 즉시 오류. BAT-034 (dcy-023): allocated_capital 죽은 필드 전 경로 제거 (domain·intent· persistence·snapshot·CLI). 마이그레이션 013(비가역 DROP). 외부 발신자 unknown key 무시 수신 의미론 적용. REL-006 confirmed: BAT-026~034 통합 릴리즈, pre-release smoke 증거 포함. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3.8 KiB
3.8 KiB
BAT-034 Design
- Status: done
- Batch: BAT-034
D1. 제거 지점 전수 목록 (소스 grep 기준)
| # | 파일 | 위치 | 제거 내용 | REQ |
|---|---|---|---|---|
| 1 | trex_core/domain/slot/models.py |
Slot.allocated_capital 필드 + EXPECTED_SLOT_FIELDS 항목 |
도메인 모델·필드셋 계약 | REQ-002 |
| 2 | trex_core/domain/slot/service.py |
transit_slot 파라미터, _apply_transition_fields 파라미터·INACTIVE clear·carry-forward replace(...) |
설정/전이 경로 | REQ-002 |
| 3 | trex_core/application/intents.py |
BuyIntent.allocated_capital 필드, submit_buy dedup payload 키, _admit_buy→transit_slot 전달 |
intent 계약·admission | REQ-007 |
| 4 | trex_core/application/messaging_handlers.py |
buy payload _opt_float(body.get("allocated_capital")) 파싱 |
수신 무시(즉시 제거) | REQ-007 |
| 5 | trex_core/adapters/persistence/postgresql.py |
_SLOT_COLUMNS 문자열, UPDATE 절, _row_to_slot 인덱스 매핑(컬럼 제거로 인덱스 시프트 — 주석 포함 재정렬) |
flat 매핑 | REQ-006 |
| 6 | trex_core/adapters/persistence/sql/013_drop_allocated_capital.sql |
신규 — ALTER TABLE daily_slot DROP COLUMN IF EXISTS allocated_capital; |
스키마 | REQ-006 |
| 7 | trex_core/application/portfolio.py |
slots[] 항목의 "allocated_capital" 키 |
snapshot 노출 | REQ-028 |
| 8 | trex_core/runtime/cli.py |
--capital argparse 인자, _cmd_enter summary·payload, _print_slot_detail 행 |
CLI 표면 | REQ-032 |
테스트: tests/ 전수 grep 으로 fixture·assert 의 allocated_capital/--capital 참조 정리 (BAT-033 의 AC-7 테스트는 보존).
D2. 마이그레이션 013 (비가역 drop)
-- BAT-034 / dcy-023 / REQ-006 (CHG-20260610-02): drop dead column (비가역).
-- allocated_capital 은 사이징·회계·전략 결정 어디에도 소비되지 않는 죽은 메타데이터
-- (dcy-023 §3 전수 추적). 실제 주문 수량은 slot.qty 가 단독 결정(dcy-021 계약).
-- Idempotent via IF EXISTS. Rollback = 사전 백업 복원 (BAT-030/011 선례 준용).
ALTER TABLE daily_slot DROP COLUMN IF EXISTS allocated_capital;
- 적용: 코드 배포와 동시(
apply_migrations데몬 기동 시 자동, dcy-023 OQ-2 운영자 결정). - 롤백: 구 코드 UPDATE 절이 컬럼을 참조하므로 공존 불가 — release 문서에 (1) 적용 전
daily_slot백업, (2) 롤백 시 백업 복원 + 구 리비전 절차 명시. - 검증: 테스트 DSN(
trex_core_test)에서만 round-trip — 운영 DB 미사용.
D3. 수신-무시 시맨틱 (REQ-007 AC-6)
- messaging handler 의 파싱 제거가 곧 수신-무시다 — RabbitMQ payload 는 관용적 계약이라 외부 발신자(trex-orb-v1,
intent_builder.py:56)가 키를 계속 보내도 읽히지 않는 unknown key 가 될 뿐. - 검증 테스트:
allocated_capital키를 포함한 buy payload → 정상 admit + 슬롯·intent_log 에 미반영. submit_buydedup payload(intent_log)에서 키 제거 — dedup 은 intent_id 기준이라 동작 영향 없음.
D4. 인덱스 시프트 주의 (postgresql.py)
_SLOT_COLUMNS에서allocated_capital(6번째) 제거 시_row_to_slot의 이후 모든 row 인덱스가 1씩 당겨진다 — 위치 주석(# limit_price(5) allocated_capital(6) order_id(7) ...)을 실제 순서로 재작성하고, 드리프트 테스트(EXPECTED_SLOT_FIELDS↔ information_schema)가 정합을 강제한다.
D5. 변경하지 않는 것
qty기반 집행 경로(qty = int(slot.qty or 0)) — 불변 (NFR-3).- BAT-033 의
--qty필수 guard(AC-7) — 보존. - 외부 전략 모듈 송신 코드 — 범위 밖(운영자 확인).
- baseline
docs/project-structure.md/docs/runtime-flows.md— allocated_capital 직접 기술 없음 확인(dcy-023 confirm 시점) → 갱신 불요, 검증 단계에서 재확인만.