feat(rel-007): dcy-025/024 + BAT-035/036 — slots.req 즉시 교체 + safety_sell_enabled
BAT-035 (dcy-025): trex.snapshot.req → trex.slots.req 즉시 교체
- topology: SNAPSHOT_REQ_QUEUE 제거, SLOTS_REQ_QUEUE = "trex.slots.req" 추가
- portfolio.py: View/build_snapshot_envelope/SnapshotEnvelope/_asset_to_dict 제거;
slot_to_dict 시그니처 확장(snapshot_store/watchdog_store/pause_store/watchdog_timeout_sec)
— asset_quantity(hub)/cash_balance/cash_estimated/warned/watchdog{}/paused 병합 (REQ-074)
- messaging_handlers.py: make_snapshot_rpc_handler 제거, make_slots_rpc_handler 추가
— filter(all/inactive/pending/holding/error) + spy(bool) 처리; strategy 필드 제외 (REQ-073/074)
- daemon.py: _snapshot_rpc_loop → _slots_rpc_loop, make_slots_rpc_handler 연결
- cli.py: universe/slots → slots_queue + spy=True + server-side filter; buyable→inactive 매핑 (REQ-063)
- rabbitmq.py: snapshot_queue → slots_queue
- docs: interface-contract.md + runtime-flows.md slots.req 계약으로 업데이트 (REQ-075)
- REQ-028: Implemented → Deprecated (코드 삭제 완료)
- 테스트: test_snapshot_handler/selection/rpc_watchdog/messaging_snapshot_consumer 삭제;
test_slots_handler.py(신규, 13 cases), test_killswitch_masking_resume 재작성,
test_ledger_option_d._apply_cash_estimate → slots handler 경유, test_topology/cli_operator 갱신
BAT-036 (dcy-024): per-instance safety_sell_enabled 플래그
- config.py: DaemonInstanceConfig + DaemonConfig 에 safety_sell_enabled: bool = True 추가;
from_toml 파싱, from_config 전파
- daemon.py: start() workers 조건부 — safety_sell_enabled=false 시 trex-safety-sell 미기동 + WARNING
- tests: test_instance_config.py 에 safety_sell_enabled 파싱 3개 케이스 추가
REQ: 073/074/075/021/034/063/048/005 Approved → Implemented
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,11 +16,13 @@
|
||||
2. Given 기동된 데몬, When 종료 시그널, Then 진행 중 요청을 정리하고 graceful shutdown 한다.
|
||||
3. Given 데몬 lifecycle, When 거래일 시작(기동/스케줄), Then 슬롯 preallocate 가 멱등하게 1회 수행된다(공개 엔드포인트 없이).
|
||||
4. Given `pyproject.toml`, When 확인, Then FastAPI·uvicorn·psycopg 의존성과 데몬 console_scripts 가 존재한다.
|
||||
5. (CHG-20260611-01) Given `safety_sell_enabled=false`, When `daemon.start()`, Then 스레드 목록에 `trex-safety-sell` 이 없고 RUNNING 로그에 `safety_sell_enabled=false` + `no autonomous liquidation` 경고가 포함된다. `true`(기본)이면 기존과 동일.
|
||||
6. (CHG-20260611-01) Given `safety_sell_enabled` 임의 값, When 데몬 동작, Then `ExecutionService`·운영자 CLI exit/cancel·kill-switch·전략 sell intent 는 영향받지 않는다(자율 청산 워커만 게이팅).
|
||||
|
||||
## Impacted Area
|
||||
- Docs: docs/runtime-flows.md(데몬 흐름), docs/project-structure.md(런타임 레이어) — REQ-009 에서 정합
|
||||
- Modules: pyproject.toml, trex_core/ 하위 데몬 런타임/엔트리포인트(애플리케이션 레이어)
|
||||
- Tests: 데몬 기동/healthz/shutdown 통합테스트
|
||||
- Docs: docs/runtime-flows.md(데몬 흐름; CHG-20260611-01 safety-sell 비활성 모드 플로우), docs/project-structure.md(런타임 레이어) — REQ-009 에서 정합
|
||||
- Modules: pyproject.toml, trex_core/ 하위 데몬 런타임/엔트리포인트(애플리케이션 레이어), (CHG-20260611-01) `trex_core/runtime/daemon.py` `start()` 워커 조건부 구성
|
||||
- Tests: 데몬 기동/healthz/shutdown 통합테스트, (CHG-20260611-01) safety-sell 워커 게이팅
|
||||
|
||||
## Notes
|
||||
- 프레임워크 FastAPI+uvicorn(dcy-002 OQ-2). API 엔드포인트 자체는 REQ-007/008, 영속화는 REQ-006.
|
||||
@@ -229,3 +231,45 @@
|
||||
#### Validation Plan
|
||||
|
||||
- dcy-020 reconcile 배치 verification 으로 대체.
|
||||
|
||||
### CHG-20260611-01
|
||||
|
||||
- Date: 2026-06-11
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
|
||||
- (change-req, dcy-024) 데몬 부트스트랩 `start()` 의 workers 구성을 **`safety_sell_enabled`(REQ-048 CHG-20260611-01) 조건부**로 한다 — `false` 면 `trex-safety-sell` 워커 스레드를 workers 리스트(`daemon.py:335`)에 포함하지 않는다(스레드 미기동이 물리적으로 자율 청산 차단, run_once if-가드보다 강함). 기동 RUNNING 로그에 `safety_sell_enabled=<true|false>` 를 출력하고 `false` 면 `no autonomous liquidation` 경고를 남긴다. `ExecutionService`·운영자 CLI(`enter`/`exit`/`cancel`)·kill-switch·messaging 핸들러는 불변(자율 청산 워커만 OFF). `docs/runtime-flows.md` 에 비활성 모드 플로우 반영.
|
||||
|
||||
#### Intent
|
||||
|
||||
- 관찰 전용·중장기 보유 인스턴스에서 자율 청산(forced_close/SL·TP/장마감)을 끄고 전략·운영자 지시 매도만 허용(dcy-024 FR-2/FR-3, issue #15).
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
|
||||
- Added:
|
||||
- AC-5: `safety_sell_enabled == False` 이면 `daemon.start()` 후 스레드 목록에 `trex-safety-sell` 이 없고, RUNNING 로그에 `safety_sell_enabled=false` + `no autonomous liquidation` 경고가 포함된다. `True`(기본)이면 기존과 동일 기동 + 회귀 없음.
|
||||
- AC-6: `safety_sell_enabled` 와 무관하게 `ExecutionService`·운영자 CLI exit/cancel·kill-switch·전략 sell intent 는 정상 동작한다(자율 청산 워커만 게이팅).
|
||||
- Updated/Removed: none
|
||||
|
||||
#### Impacted Area Delta
|
||||
|
||||
- Modules: `trex_core/runtime/daemon.py`(`start()` workers 조건부 구성 + 기동 로그)
|
||||
- Docs: `docs/runtime-flows.md`(safety-sell 비활성 모드 플로우)
|
||||
- Tests: tests/runtime/(enabled=False → `trex-safety-sell` 스레드 부재, 로그 경고; enabled=True 회귀)
|
||||
|
||||
#### Delivery Trace Delta
|
||||
|
||||
- Batches: 신규 batch(REQ-048 CHG-20260611-01 과 동일 배치, dcy-024)
|
||||
- Releases: none
|
||||
|
||||
#### Revalidation Impact
|
||||
|
||||
- Reverification Needed: yes (신규 batch 에서 AC-5/6 검증)
|
||||
- Existing Implementation Invalidated: no (기본 true 시 기존 동작 불변, 조건부 게이팅 additive) — 단 신규 AC 미구현
|
||||
- Status Recommendation: Implemented → Approved (신규 AC-5/6 미구현, batch 재검증 후 Implemented 복귀)
|
||||
- Follow-up Action: draft-batch → run-batch-implementation → verification → confirm-req-implemented
|
||||
|
||||
#### Validation Plan
|
||||
|
||||
- 신규 BAT: `enabled=False` config 주입 + `daemon.start()` 후 thread 이름에 `trex-safety-sell` 부재 단위, RUNNING 로그 경고, run-the-app 스모크(비활성 모드 holding 유지·전략 sell 정상), enabled=True 회귀.
|
||||
|
||||
Reference in New Issue
Block a user