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>
4.2 KiB
4.2 KiB
BAT-035 Planning
- Status: done
- Batch: BAT-035
- Profile: standard
Included REQ
- REQ-073: trex.slots.req RPC 계약 (Interface/High) — 큐 교체, filter/spy, 응답 slots+health only
- REQ-074: 슬롯 단일 행 스키마 (Data/High) — asset_quantity+qty+warned, cash_balance+cash_estimated, watchdog nested, paused
- REQ-075: baseline 문서 정합 (Documentation/Medium) — interface-contract/runtime-flows
- REQ-021 CHG-20260611-01: 토폴로지 큐명 snapshot→slots 교체
- REQ-034 CHG-20260611-01: watchdog 트리거=slots.req 기본/spy=무터치, 행 흡수
- REQ-063 CHG-20260611-01: CLI slots.req+spy=true, --status→filter 매핑
Delivery Plan
M1: 토폴로지 + 인프라 계약 교체
trex_core/adapters/messaging/topology.py: SNAPSHOT_REQ_QUEUE → SLOTS_REQ_QUEUE ("trex.slots.req"),snapshot_queue()→slots_queue()docs/interface-contract.md: trex.snapshot.req 섹션 제거, trex.slots.req 계약(요청 {filter, spy}, 응답 {slots[], degraded/reason/message}, 필드별 정본 출처 표) 추가docs/runtime-flows.md: read 흐름 snapshot→slots 교체
M2: messaging_handlers — slots 핸들러 신설 + snapshot 핸들러 제거
make_snapshot_rpc_handler전체 제거make_slots_rpc_handler신설: filter(str) / spy(bool) 파싱, filter 분기 슬롯 조회, spy=false → holding watchdog 터치, 응답 {slots, degraded, reason, message} only_attach_watchdogtop-level 함수 제거 (watchdog 처리가 핸들러 내부로 흡수)
M3: portfolio — slot_to_dict 확장 + View 폐기 + snapshot envelope 제거
portfolio.py:Viewenum 제거,build_snapshot_envelope제거slot_to_dict(s, snapshot_store=None, watchdog_store=None, pause_store=None)확장:- 슬롯/코어 정본 필드(기존 유지)
asset_quantity(snapshot_store → hub 정본) +qty(슬롯 미러 s.qty) +warned(qty≠asset_quantity)cash_balance+cash_estimated(snapshot_store)watchdog: {expired: bool, last_seen: str|null}nested (watchdog_store)paused: bool(pause_store)
M4: CLI — slots.req 사용 + spy=true + filter 매핑
trex_core/interfaces/cli.py(또는 해당 모듈): 슬롯 조회 시 slots.req + spy=true,--status인자→filter 매핑 (all/inactive/pending/holding/error, 기존 "buyable" → "inactive")
M5: 테스트 + 회귀
- tests/adapters/messaging/: topology 단언 (SLOTS_REQ_QUEUE 존재, SNAPSHOT_REQ_QUEUE 부재)
- tests/application/: slots 핸들러 filter·spy·응답 키 집합, watchdog 터치/무터치, degraded 신호, portfolio slot_to_dict 확장 필드 + divergence + warned + cash_estimated + paused holding 직교, strategy 필드 부재
- 전체 suite green
Dependencies
- Internal: REQ-062(hub 정본 + 슬롯 미러 정합 — 이번 배치가 그 계약을 표면에 구현), PauseStore, WatchdogStore 기존 API 재사용
- External: trex-orb-v1 lockstep 대응(배포 전 확인)
Design Gate
- Design Required Before Implementation: yes
- Reason: topology.py 큐 선언 변경(REQ-021), messaging_handlers.py 핸들러 신설/제거(REQ-073), portfolio.py slot_to_dict 서명 변경 + View 폐기(REQ-074)가 상호 연결된 인터페이스 변경. 제거 지점 전수와 새 핸들러 설계 계약을 design.md에 먼저 고정해 구현 drift를 방지.
위험 요소
- R-1 (lockstep): trex-orb-v1 이 snapshot.req 를 아직 쓰고 있으면 배포 즉시 read 실패 → 배포 전 trex-orb-v1 의 slots.req 대응 완료 여부 확인 필수
- R-2 (slot_to_dict 서명 변경): 호출 지점이 다수(messaging_handlers + CLI + 테스트) → grep 으로 호출 지점 전수 확인 후 한 번에 교체
- R-3 (build_snapshot_envelope 제거): snapshot_store wiring path 삭제 시 CLI / daemon wiring 코드에서 잔존 참조 compile 오류 → M5 회귀로 검출
검증 계획 (요약)
- topology: SLOTS_REQ_QUEUE 존재, SNAPSHOT_REQ_QUEUE 부재 assert
- slots 핸들러: filter 분기(all/inactive/pending/holding/error), spy 터치/무터치, 응답 키 집합 {slots/degraded/reason/message} only, strategy 필드 부재
- slot_to_dict: asset_quantity(hub) + qty(mirror) + warned(divergence) + cash_balance + cash_estimated + watchdog:{expired,last_seen} + paused 포함
- 회귀: 전체 suite green