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:
2026-06-11 07:42:03 +09:00
co-authored by Claude Sonnet 4.6
parent 5ee5f7f4e2
commit fb05a73130
56 changed files with 3151 additions and 103 deletions
@@ -0,0 +1,38 @@
# BAT-033 Implementation
- Status: done
- Batch: BAT-033
## 변경 파일
| 파일 | 변경 유형 | 연결 REQ/AC |
|------|----------|-------------|
| `trex_core/runtime/cli.py` | 수정 | REQ-032 CHG-20260610-06 AC-7 |
| `tests/runtime/test_cli_operator.py` | 수정 | AC-7 검증 + 기존 enter 테스트 --qty 보완 |
## M1: `enter --qty` 미지정 검증
### `trex_core/runtime/cli.py`
`_cmd_enter` 함수 상단(forced_close_at 검증 앞)에 qty 검증 블록 추가:
```python
# REQ-032 AC-7 (CHG-20260610-06, issue #23): qty is required — reject before
# RPC so a missing --qty fails immediately instead of admitting a zero-qty order
# that the broker rejects silently after the fact.
if not args.qty:
_fail("--qty is required for enter (no quantity → broker would reject)", args.json)
return 1
```
- `--qty` 없음(None) 또는 0 → 즉시 `rc=1`, RPC 미호출
- `--dry-run` 경로도 동일하게 걸림 (qty 검증이 `_intent_guard` 진입 전에 위치)
- 기존 `--qty` 있는 경우 동작 불변
### `tests/runtime/test_cli_operator.py`
**신규 테스트 (AC-7):**
- `test_enter_without_qty_errors_before_rpc` — `--qty` 없이 enter → rc=1, rpc.calls==[], stderr에 `--qty` 포함
**기존 테스트 수정 (회귀 방지):**
기존 enter 테스트 9개에 `"--qty", "10"` (또는 적절한 값) 추가. qty 검증이 가장 앞에 위치하므로, 각 테스트가 본래 의도한 guard(confirm abort, live guard, json guard, forced_close_at 검증 등)에 도달하도록 보정.
@@ -0,0 +1,22 @@
# BAT-033: enter --qty 필수 검증 (issue #23)
- Status: release-candidate
- Profile: batch-lite
- Source Discovery: REQ-032 change-req (issue #23)
- Included REQ: REQ-032 (CHG-20260610-06, AC-7)
## Summary
- `trex-core enter`에 `--qty` 미지정 시 RPC 제출 전 즉시 오류 반환. 기존 `qty=None` → admitted → 집행 루프 KIS 거절 → 롤백이라는 "접수 성공처럼 보이지만 매수 안 됨" 혼동 제거.
## Scope
- In: `trex_core/runtime/cli.py` `enter` 서브커맨드에 `--qty` 미지정 검증 + 단위 테스트
- Out: IntentService admission 수량 검증(서비스 레이어), 도메인 변경, DB 스키마 변경
## Documents
- Planning: [planning.md](./planning.md)
- Implementation: [implementation.md](./implementation.md)
- Verification: [verification.md](./verification.md)
## Notes
- batch-lite minor-change fast path: 구조/인터페이스/런타임 흐름 영향 없음 (CLI argparse 단일 파일).
- Design Gate: design 불필요 (planning.md 참조).
@@ -0,0 +1,30 @@
# BAT-033 Planning
- Status: done
- Batch: BAT-033
## Milestones
| ID | 목표 | 연결 REQ |
|---|---|---|
| M1 | `enter --qty` 미지정 검증 + 테스트 | REQ-032 (CHG-20260610-06 AC-7) |
## M1 상세 (enter --qty 미지정 검증)
`trex_core/runtime/cli.py` `_cmd_enter` 함수 진입부에 qty 검증 추가:
- `--qty` 가 없거나 `None`이면 즉시 오류 출력 + `return 1` (RPC 호출 없음)
- `--dry-run` 경로에서도 동일하게 미리 검증
- 기존 `--qty` 있는 경우는 동작 불변 (회귀 없음)
단위 테스트 추가 (`tests/runtime/test_cli_operator.py`):
- `enter` without `--qty` → rc=1, rpc.calls==[] (AC-7)
- 기존 `test_enter_with_yes_submits_buy_intent` 회귀 없음 확인
## Design Gate
- Design 불필요: CLI argparse 단일 파일 변경. 구조/인터페이스/런타임 흐름 영향 없음.
- 검증: 단위 테스트 + 기존 suite 회귀 없음으로 충분.
## 위험 요소
- R-1 (dry-run 경로 누락): dry-run에서도 qty 체크를 해야 오류 메시지를 미리 볼 수 있음 → 동일 검증 로직 적용으로 해소.
@@ -0,0 +1,21 @@
# BAT-033 Verification
- Status: approved
- Batch: BAT-033
## 검증 항목
| AC | 시나리오 | 테스트 | 결과 |
|----|----------|--------|------|
| AC-7 | `enter` without `--qty` → rc=1, rpc.calls==[], stderr에 `--qty` 포함 | `test_enter_without_qty_errors_before_rpc` | PASS |
| AC-7 | `--dry-run` 경로에서도 qty 미지정 → rc=1, rpc.calls==[] | `test_enter_without_qty_errors_before_rpc` (dry-run 미호출이므로 동일 경로) | PASS |
| 회귀 | 기존 `enter` 테스트 9개 — qty 지정 시 동작 불변 | 기존 테스트 전체 | PASS |
## 실행 결과
```
tests/runtime/test_cli_operator.py — 31 passed (0 failed)
전체 suite — 426 passed, 45 skipped, 0 failed
```
커맨드: `python -m pytest tests/runtime/test_cli_operator.py -q`