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:
2026-06-11 14:45:45 +09:00
co-authored by Claude Opus 4.8
parent fb05a73130
commit f0ad37747b
44 changed files with 1963 additions and 1189 deletions
@@ -29,13 +29,14 @@
7. (CHG-20260609-01) Given `--config <name> [--config-path <dir>]`, When `resolve_config_toml`, Then `<dir or ./config>/<name>.toml` 로 해석되고 `.toml` 이 없으면 자동 부착된다.
8. (CHG-20260609-01) Given 슬래시 포함(경로형) `--config` 값, When 해석, Then `--config-path` 와 무관하게 명시 경로로 그대로 사용된다(하위호환).
9. (CHG-20260609-01) Given 운영자 CLI 가 `--config-path` 와 함께 호출, When `_resolve_instance`, Then 동일 `resolve_config_toml` 규칙으로 TOML 을 찾아 instance_key 를 해석한다.
10. (CHG-20260611-01) Given per-instance TOML `safety_sell_enabled`(부재 시 `true`), When `from_toml`/`from_config`, Then 값이 파싱되어 `DaemonConfig` 로 전파된다.
## Impacted Area
- Docs:
- `docs/project-structure.md` — 설정 파일 계층(TOML + env) (REQ-051 처리)
- Modules:
- `trex_core/runtime/config.py` — `DaemonInstanceConfig` + `from_toml` + `from_config` 병합, (CHG-20260609-01) `resolve_config_toml`/`DEFAULT_CONFIG_DIR`
- `trex_core/runtime/config.py` — `DaemonInstanceConfig` + `from_toml` + `from_config` 병합, (CHG-20260609-01) `resolve_config_toml`/`DEFAULT_CONFIG_DIR`, (CHG-20260611-01) `safety_sell_enabled` 필드
- 데몬 진입점(`trex_core/runtime/daemon.py:main` 또는 `__main__`) — `--config` 필수 파싱(argparse), (CHG-20260609-01) `--config-path`
- 운영자 CLI `trex_core/runtime/cli.py` — (CHG-20260609-01) `--config-path` + `_resolve_instance` 통일
- `.gitignore` — 인스턴스 TOML 패턴
@@ -269,3 +270,44 @@
#### Validation Plan
- tests/runtime/test_config_resolution.py(resolve_config_toml/경로형 폴백/CLI `--config-path` 라우팅) + 라이브 스모크(name·path 형태 동일 결과). 전체 375 passed, ruff clean.
### CHG-20260611-01
- Date: 2026-06-11
- Author: Justin Ko
#### Change Summary
- (change-req, dcy-024) per-instance TOML 에 **`safety_sell_enabled: bool = True`** 키 추가 — 자율 청산(safety-sell 워커) 인스턴스별 ON/OFF. `DaemonInstanceConfig.from_toml` 파싱 + `from_config` → `DaemonConfig` 전파. 기본값 `true`(미지정 시 기존 동작). env 미노출(`max_active_slots`/`default_order_timeout_sec` 선례, dcy-024 OQ-2). 실제 워커 게이팅은 REQ-005 CHG-20260611-01. SafetySellConfig(env) 변경 없음.
#### Intent
- 당일 매매 인스턴스(enabled=true)와 중장기 보유 인스턴스(enabled=false)가 인스턴스마다 다른 자율 청산 모드를 갖도록 운영 모드를 TOML 로 일원화(dcy-024 FR-1, issue #15).
#### Acceptance Criteria Delta
- Added:
- AC-10: per-instance TOML `safety_sell_enabled` optional 키(부재 시 `true`)를 `DaemonInstanceConfig.from_toml` 가 파싱하고 `from_config` 가 `DaemonConfig` 로 전파한다.
- Updated/Removed: none
#### Impacted Area Delta
- Modules: `trex_core/runtime/config.py`(`DaemonInstanceConfig.safety_sell_enabled` + from_toml/from_config 전파)
- Docs: `config/instance.example.toml`
- Tests: tests/runtime/test_instance_config.py(기본값 true / TOML false 전파)
#### Delivery Trace Delta
- Batches: 신규 batch(REQ-005 CHG-20260611-01 과 동일 배치, dcy-024)
- Releases: none
#### Revalidation Impact
- Reverification Needed: yes (신규 batch 에서 AC-10 검증)
- Existing Implementation Invalidated: no (optional 키 additive, 기존 TOML 호환) — 단 신규 AC 미구현
- Status Recommendation: Implemented → Approved (신규 AC-10 미구현, batch 재검증 후 Implemented 복귀)
- Follow-up Action: draft-batch → run-batch-implementation → verification → confirm-req-implemented
#### Validation Plan
- 신규 BAT: `from_toml` 기본값(true) + TOML `safety_sell_enabled = false` from_config 전파 단위.