Files
trex-core/docs/batches/bat-036_20260611_safety-sell-disable-mode/planning.md
T
genichinandClaude Opus 4.8 f0ad37747b 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>
2026-06-11 14:45:45 +09:00

2.4 KiB

BAT-036 Planning

  • Status: done
  • Batch: BAT-036
  • Profile: standard

Included REQ

  • REQ-048 CHG-20260611-01: DaemonInstanceConfig.safety_sell_enabled: bool=True, from_toml/from_config 파싱, DaemonConfig 전파 (AC-10)
  • REQ-005 CHG-20260611-01: daemon.start() 조건부 workers — safety_sell_enabled=False 시 trex-safety-sell 제외 + RUNNING 로그 + 경고 로그 (AC-5/6)

Delivery Plan

M1: config.py — DaemonInstanceConfig 필드 추가

  • trex_core/runtime/config.py:DaemonInstanceConfig 에 safety_sell_enabled: bool = True dataclass 필드 추가
  • from_toml(): data.get("safety_sell_enabled", True) 파싱
  • DaemonConfig.from_config(): DaemonConfig 생성 시 inst.safety_sell_enabled 전파

M2: daemon.py — start() 조건부 workers

  • trex_core/runtime/daemon.py:328~337 workers 리스트 구성 부분에서 조건 분기:
    if self._config.safety_sell_enabled:
        workers.append(("trex-safety-sell", self._safety_sell_loop))
    else:
        logger.warning("safety_sell disabled — trex-safety-sell worker not started")
    
  • RUNNING 로그(기존 구조 안에서)로 비활성 상태 가시화

M3: 테스트

  • config 파싱: TOML safety_sell_enabled=false → False; 키 부재 → True
  • daemon start: safety_sell_enabled=False → trex-safety-sell 스레드 미기동 단언
  • AC-6: ExecutionService/exit/cancel/kill-switch 경로는 이번 M1~M2 변경으로 건드리지 않음(회귀 테스트로 확인)

Dependencies

  • Internal: DaemonConfig 내 DaemonInstanceConfig 전파 경로(from_config → DaemonInstanceConfig.from_toml)
  • External: 없음

Design Gate

  • Design Required Before Implementation: yes
  • Reason: DaemonConfig ↔ DaemonInstanceConfig 전파 경로와 daemon.start() workers 리스트 수정 지점을 design.md 에 먼저 확정해 구현 오류를 방지.

위험 요소

  • R-1 (absent=true 누락): from_toml 에서 get 기본값을 False 로 잘못 설정하면 기존 인스턴스 동작 파괴 → 단위 테스트로 absent→True 확인
  • R-2 (DaemonConfig 전파): DaemonConfig 에 safety_sell_enabled 를 전달하지 않으면 daemon.start() 에서 참조 실패 → M1 에서 전파 경로를 먼저 확인

검증 계획 (요약)

  • TOML 파싱: present=false→False, present=true→True, absent→True
  • daemon.start() workers: False → trex-safety-sell 제외, True → 포함
  • 다른 워커(trex-execution 등) 영향 없음
  • 전체 suite green