feat(rel-006): dcy-022/023 + BAT-032~034 — 실행 정책·qty 검증·allocated_capital 제거 통합
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>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# 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)
|
||||
|
||||
```sql
|
||||
-- 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_buy` dedup 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 시점) → 갱신 불요, 검증 단계에서 재확인만.
|
||||
@@ -0,0 +1,27 @@
|
||||
# BAT-034 Implementation
|
||||
|
||||
- Status: done
|
||||
- Batch: BAT-034
|
||||
|
||||
## 변경 파일
|
||||
|
||||
| 파일 | 변경 | Milestone / REQ |
|
||||
|------|------|----------------|
|
||||
| `trex_core/domain/slot/models.py` | `Slot.allocated_capital` 필드 + `EXPECTED_SLOT_FIELDS` 항목 제거 | M1 / REQ-002 |
|
||||
| `trex_core/domain/slot/service.py` | `transit_slot`·`_apply_transition_fields` 파라미터, INACTIVE clear, carry-forward 제거 | M1 / REQ-002 |
|
||||
| `trex_core/application/intents.py` | `BuyIntent.allocated_capital` 필드, `submit_buy` dedup payload 키, `_admit_buy`→`transit_slot` 전달 제거 | M1 / REQ-007 |
|
||||
| `trex_core/application/messaging_handlers.py` | buy payload 파싱 제거 + 수신-무시 주석 (AC-6) | M1 / REQ-007 |
|
||||
| `trex_core/adapters/persistence/postgresql.py` | `_SLOT_COLUMNS`·UPDATE 절·`_row_to_slot`(인덱스 6 제거, 이후 1씩 시프트 + 위치 주석 재작성) | M2 / REQ-006 |
|
||||
| `trex_core/adapters/persistence/sql/013_drop_allocated_capital.sql` | 신규 — `DROP COLUMN IF EXISTS`(멱등) | M2 / REQ-006 |
|
||||
| `trex_core/application/portfolio.py` | snapshot `slots[]` 항목의 `allocated_capital` 키 제거 | M3 / REQ-028 |
|
||||
| `trex_core/runtime/cli.py` | `--capital` argparse 인자, `_cmd_enter` summary/payload, `_print_slot_detail` 행 제거 | M3 / REQ-032 |
|
||||
| `tests/domain/slot/test_service.py` | `allocated_capital` 인자/assert 제거 | M4 |
|
||||
| `tests/runtime/test_cli_operator.py` | fixture 키·`--capital` 인자 제거, `test_enter_rejects_capital_option`(AC-8) 신규, `test_enter_with_yes_submits_buy_intent` 에 payload 부재 assert | M4 |
|
||||
| `tests/application/test_messaging_intent_consumer.py` | `test_buy_payload_allocated_capital_is_ignored`(AC-6 unknown-key 무시) 신규 | M4 |
|
||||
| `tests/application/test_execution_policy.py` | 잔여 lint 정리(F401/F841 — BAT-032 잔재, 본 배치 변경과 무관) | M4 |
|
||||
|
||||
## 설계 정합
|
||||
|
||||
- design.md D1 제거 지점 8개 전부 처리. D4 인덱스 시프트는 위치 주석 재작성 + 드리프트 테스트로 검증.
|
||||
- D3 수신-무시: 파싱 제거 = unknown key 무시. 전용 테스트로 고정.
|
||||
- D5 불변 확인: `qty` 집행 경로·BAT-033 AC-7 guard·외부 모듈·baseline 문서 모두 미변경.
|
||||
@@ -0,0 +1,24 @@
|
||||
# BAT-034: allocated_capital 죽은 필드 제거 — CLI·intent·도메인·영속·snapshot 정리 (dcy-023)
|
||||
|
||||
- Status: release-candidate
|
||||
- Profile: standard
|
||||
- Source Discovery: dcy-023 (issue #22)
|
||||
- Included REQ: REQ-002 (CHG-20260610-02), REQ-006 (CHG-20260610-02), REQ-007 (CHG-20260610-02), REQ-028 (CHG-20260610-01), REQ-032 (CHG-20260610-07)
|
||||
|
||||
## Summary
|
||||
- dcy-023: 주문 사이징·회계·전략 결정 어디에도 쓰이지 않는 죽은 필드 `allocated_capital` 을 설정(CLI `--capital`)→운반(buy intent)→영속(daily_slot 컬럼)→표시(snapshot `slots[]`·CLI detail) 전 경로에서 제거한다. dcy-021 사이징 계약(전략이 qty 계산, core 미관여) 확정의 귀결로, capital 기반 사이징 오해를 원천 제거한다.
|
||||
|
||||
## Scope
|
||||
- In: CLI `--capital` argparse 제거 + `slots` detail 행 제거(REQ-032), BuyIntent 필드·admission·payload 파싱 즉시 제거(REQ-007), Slot 모델·`EXPECTED_SLOT_FIELDS`·SlotService 경로 제거(REQ-002), 마이그레이션 013 컬럼 drop + persistence flat 매핑 제거(REQ-006), snapshot `slots[]` 노출 제거(REQ-028), 관련 테스트 정리.
|
||||
- Out: 외부 전략 모듈(trex-orb-v1) 송신 코드 수정(운영자 확인: 무시 — unknown key 무해), capital 기반 자동 사이징 도입(dcy-021 에서 불채택 확정), 다른 슬롯 필드 정리.
|
||||
|
||||
## Documents
|
||||
- Planning: [planning.md](./planning.md)
|
||||
- Design: [design.md](./design.md)
|
||||
- Implementation: [implementation.md](./implementation.md)
|
||||
- Verification: [verification.md](./verification.md)
|
||||
|
||||
## Notes
|
||||
- 마이그레이션 013 은 비가역 drop — BAT-030 의 011 선례 준용(코드 배포와 동시 적용, release 문서에 사전 백업·롤백 절차 명시, dcy-023 OQ-2).
|
||||
- BAT-033(REQ-032 AC-7, release-candidate)과 같은 CLI/테스트 파일을 수정하므로 enter 테스트 정합 유지.
|
||||
- 본 배치 완료 후 REQ-002/006/007/028/032 confirm-req-implemented.
|
||||
@@ -0,0 +1,34 @@
|
||||
# BAT-034 Planning
|
||||
|
||||
- Status: done
|
||||
- Batch: BAT-034
|
||||
|
||||
## Milestones
|
||||
|
||||
| ID | 목표 | 연결 REQ |
|
||||
|---|---|---|
|
||||
| M1 | 도메인·intent 계약 제거 — Slot 모델/EXPECTED_SLOT_FIELDS/SlotService + BuyIntent/admission/payload 파싱 | REQ-002 (CHG-02), REQ-007 (CHG-02) |
|
||||
| M2 | 영속 제거 — 마이그레이션 013(`DROP COLUMN IF EXISTS`) + postgresql.py flat 매핑 | REQ-006 (CHG-02) |
|
||||
| M3 | 표면 제거 — snapshot `slots[]` 노출 + CLI `--capital` argparse·summary·payload·`slots` detail 행 | REQ-028 (CHG-01), REQ-032 (CHG-07) |
|
||||
| M4 | 테스트 정리 + 회귀 — allocated_capital 참조 전수 정리, unknown key 무시 테스트, argparse 거부 테스트, 전체 suite green | 전 REQ |
|
||||
|
||||
## 작업 순서 근거
|
||||
|
||||
- M1(안쪽 계약)→M2(영속)→M3(바깥 표면) 순서로 제거하면 각 단계에서 컴파일/테스트 오류가 다음 제거 지점을 가리킨다. M4 는 전 단계 누락 검출.
|
||||
- 모든 변경이 "제거"라 단계 간 의존이 단방향(도메인 필드가 사라지면 매핑·노출이 따라 사라져야 함).
|
||||
|
||||
## Design Gate
|
||||
|
||||
- design 필요: **yes** — 5개 REQ·7개 모듈에 걸친 데이터 계약 변경 + 비가역 마이그레이션. 제거 지점 전수 목록과 마이그레이션/롤백 절차를 design.md 에 고정한다.
|
||||
|
||||
## 위험 요소
|
||||
|
||||
- R-1 (비가역 drop): 마이그레이션 013 적용 후 구 리비전과 공존 불가(구 코드 UPDATE 절이 컬럼 참조) → release 문서에 사전 백업 + 롤백(컬럼 재추가 또는 백업 복원) 절차 명시. 검증은 테스트 DSN 에서만.
|
||||
- R-2 (참조 누락): 테스트·fixture 의 allocated_capital 잔존 참조로 suite 실패 → `grep -rn allocated_capital trex_core/ tests/` 전수 0건을 M4 DoD 로 설정.
|
||||
- R-3 (BAT-033 정합): 같은 CLI/테스트 파일 수정 — enter 테스트의 `--capital` 인자를 제거하면서 AC-7(`--qty` 필수) 테스트는 보존.
|
||||
|
||||
## 검증 계획 (요약)
|
||||
|
||||
- 단위: argparse 거부, payload allocated_capital 부재, unknown key 무시(admit 정상 + 미반영), 필드셋 계약, slots[] 스키마
|
||||
- 통합(테스트 DSN): 마이그레이션 013 멱등 적용 + information_schema 대조 + round-trip
|
||||
- 회귀: 전체 suite green + `grep` 전수 0건
|
||||
@@ -0,0 +1,26 @@
|
||||
# BAT-034 Verification
|
||||
|
||||
- Status: approved
|
||||
- Batch: BAT-034
|
||||
|
||||
## Acceptance Mapping
|
||||
|
||||
| REQ / AC | 검증 | 테스트/Evidence | 결과 |
|
||||
|----------|------|----------------|------|
|
||||
| REQ-002 AC-5 | Slot 모델·EXPECTED_SLOT_FIELDS·SlotService 경로에서 allocated_capital 부재 | `tests/domain/slot/test_contract.py`(필드셋 = dataclass fields 정합, 자동 강제) + grep 전수 0건 | PASS |
|
||||
| REQ-006 AC-5 | 마이그레이션 013 멱등 적용 + 컬럼 부재 + 드리프트 green | 테스트 DSN(trex_core_test)에서 `apply_migrations` 2회 → `013_drop_allocated_capital.sql` 적용·재적용 무해, information_schema 에 컬럼 없음 확인. PG 게이트 suite 21 passed(드리프트 가드 포함) | PASS |
|
||||
| REQ-007 AC-6 | BuyIntent 필드 부재 + unknown key 무시 | `test_buy_payload_allocated_capital_is_ignored` — allocated_capital 포함 payload 정상 admit + 슬롯 미반영 | PASS |
|
||||
| REQ-028 AC-5 | snapshot slots[] 에 키 부재 | `build_snapshot_envelope` 매핑 제거 + `test_cli_operator` fixture 정합(snapshot 스키마 테스트 green) | PASS |
|
||||
| REQ-032 AC-8 | `--capital` argparse 거부 + payload 부재 + detail 행 제거 | `test_enter_rejects_capital_option`(SystemExit 2, RPC 미호출, stderr 에 --capital) + `test_enter_with_yes_submits_buy_intent`(payload 에 키 부재) | PASS |
|
||||
| 회귀 (NFR-2/3) | 전체 suite + qty 집행 경로 불변 + BAT-033 AC-7 보존 | 전체 **428 passed, 45 skipped**, PG 게이트 **21 passed**, `ruff check` All checks passed. AC-7 테스트(`test_enter_without_qty_errors_before_rpc`) green | PASS |
|
||||
| S-1 (dcy-023) | 소스/테스트 grep 전수 | `grep -rn allocated_capital trex_core/ tests/` → 수신-무시 주석·전용 테스트 외 0건 | PASS |
|
||||
|
||||
## 환경
|
||||
|
||||
- 단위/통합: in-memory + 테스트 PostgreSQL `trex_core_test`(TREX_POSTGRESQL_TEST_DSN 파생, 운영 DB 미사용)
|
||||
- 명령: `python -m pytest -q` (전체), `python -m pytest tests/adapters/persistence/ -q` (PG 게이트)
|
||||
|
||||
## 운영 이월 (release 시 필수)
|
||||
|
||||
- 마이그레이션 013 은 비가역 — 운영 적용 전 `daily_slot` 백업, 롤백 = 백업 복원 + 구 리비전(BAT-030/011 선례). release 문서 Rollout/Rollback 에 명시할 것.
|
||||
- 운영자 스크립트/습관의 `enter --capital` 사용분은 배포 후 argparse 오류로 즉시 표면화(silent 실패 아님).
|
||||
Reference in New Issue
Block a user