# BAT-036 Design - Status: confirmed - Batch: BAT-036 ## Architecture Summary - `DaemonInstanceConfig`에 `safety_sell_enabled: bool = True` 필드를 추가하고 per-instance TOML 파싱 경로(`from_toml`)와 `DaemonConfig.from_config()` 전파 경로를 업데이트한다. - `Daemon.start()` 내부 workers 리스트 구성 시 `safety_sell_enabled` 값을 체크해 False이면 `("trex-safety-sell", self._safety_sell_loop)` 항목을 포함하지 않는다. ## Changed Areas - Docs: 없음 (docs 변경 없음) - Modules: - `trex_core/runtime/config.py` — DaemonInstanceConfig 필드 + from_toml + from_config 전파 - `trex_core/runtime/daemon.py` — start() workers 분기 - Tests: - config 파싱 단위 테스트 - daemon workers 구성 테스트 ## Key Decisions 1. **absent=true 기본값**: `from_toml()` 내 `data.get("safety_sell_enabled", True)`. TOML 키 부재 시 True → 기존 배포 동작 보존. 2. **DaemonConfig 전파 경로**: `DaemonConfig.from_config()` → `DaemonInstanceConfig.from_toml()` → `DaemonInstanceConfig.safety_sell_enabled` → `DaemonConfig` 생성자 또는 속성으로 전달. `Daemon.__init__` 에서 `self._config.safety_sell_enabled` 로 참조. 3. **workers 조건 분기 위치**: `daemon.py:328` workers 리스트 구성 블록 내, `("trex-safety-sell", self._safety_sell_loop)` 항목을 조건부로 append. 리스트 구성 후 순회 루프(`for name, target in workers:`)는 변경 없음. 4. **로그 메시지**: `logger.warning("safety_sell disabled — trex-safety-sell worker not started. Autonomous safety-sell will NOT run.")`. RUNNING 로그(기존)로 전체 워커 시작 상태를 가시화. 5. **AC-6 보존**: `_safety_sell_loop` 제거가 아닌 workers 리스트 미포함. `Daemon._safety_sell_loop` 메서드 자체는 삭제하지 않는다(CLI exit/cancel/kill-switch 독립 경로는 이 메서드를 직접 호출하지 않으므로 무관). ## Edge Cases - safety_sell_enabled=True (기본): workers에 포함, 기존 동작과 동일 - safety_sell_enabled=False: workers에 미포함, 경고 로그, 나머지 워커 영향 없음 - TOML 키 오타(예: "safety_sell_enable"): get() 기본값 True 처리 → 활성화(안전한 방향) ## Architecture Impact - runtime-flows: no (daemon 기동 흐름만 경미하게 변경, 문서 갱신 불필요) - project-structure: no ## Reference Doc Update Plan - docs/interface-contract.md: 없음 - docs/runtime-flows.md: 없음