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.6 KiB
4.6 KiB
req-074: 슬롯 단일 행 스키마 — 자산·워치독·overlay 흡수 + 필드별 정본 라벨
- Status: Implemented
- Type: Data
- Priority: High
- Owner: project maintainers
Intent
trex.slots.req(REQ-073) 응답의 슬롯 행 하나가 슬롯 상태·자산 데이터·워치독·overlay 를 모두 운반해 소비자 측 배열 조인(assets[]/watchdog[])을 없앤다. 각 필드의 정본 출처(hub/슬롯·코어/워치독/overlay)를 계약에 라벨해 divergence 시 어느 값을 믿을지 모호하지 않게 한다. (dcy-025 FR-3, OQ-3 (a))
Requirement
slots[]각 행은 아래 필드를 운반한다(필드별 정본 출처 명시):- 슬롯/코어 정본:
slot_id,status(inactive/pending_buy/holding/pending_sell/error),portfolio_id,symbol,avg_price,limit_price,forced_close_at(+기존 슬롯 행 필드 유지) - 수량(REQ-062 정합, 둘 다 노출):
asset_quantity(hub 정본 — 전략 reasoning primary) +qty(슬롯 미러 — 코어 confirmed local). 정상 시 일치하며, 어긋나면warned=true로 표면화한다. 라이브 브로커 잔고는 행에 포함하지 않는다(청산/reconcile 시점 정본 — REQ-062). - 현금(hub 정본):
cash_balance+cash_estimated(bool, dcy-018 추정 현금 오버레이) - 워치독(WatchdogStore):
watchdog: {expired: bool, last_seen: ISO-8601|null}nested object — 기존 응답 top-levelwatchdog[]배열은 폐기(REQ-073). - overlay 플래그(직교 축):
paused(PauseStore),warned(reconcile/REQ-031·062) — status 와 독립이며 항상 노출(서버측 overlay 필터는 후속).
- 슬롯/코어 정본:
- strategy 계열 필드(
strategy_id/sell_strategy_id/strategy_params/active_strategy_id)는 행에 포함하지 않는다(REQ-073, dcy-025 OQ-4 — 후속 discovery 확정 시 additive 재도입). docs/interface-contract.md에 각 필드의 정본 출처(hub / 슬롯·코어 / 브로커(행 미포함) / watchdog / overlay)를 표로 명시한다(REQ-075).
Acceptance Criteria
- Given holding 자산 슬롯, When
trex.slots.req조회, Then 행에 슬롯 상태(slot_id/status/avg_price/limit_price/forced_close_at)·자산(symbol/portfolio_id/cash_balance/asset_quantity)·qty미러·watchdog:{expired,last_seen}·paused/warned가 모두 포함된다(별도 배열 조인 불요). - Given hub
asset_quantity와 슬롯 미러qty가 어긋난 자산, When 조회, Then 두 값이 그대로 노출되고warned=true다(조용한 자동 교정·숨김 없음). - Given 추정 현금 구간(dcy-018), When 조회, Then
cash_balance와cash_estimated=true가 함께 노출되고 권위값 수렴 시cash_estimated=false로 돌아온다. - Given paused 처리된 holding 자산, When
filter=holding조회, Then 행이 반환되며paused=true플래그로 표시된다(필터는 status, overlay 는 플래그 — 직교). - Given 행 스키마, When 키 검사, Then strategy 계열 필드가 없다.
Impacted Area
- Docs: docs/interface-contract.md(행 스키마 + 정본 라벨 표 — REQ-075), docs/data-model.md(노출 스키마 참조)
- Modules: trex_core/application/portfolio.py(
slot_to_dict확장 — 자산·워치독·overlay 병합), trex_core/application/messaging_handlers.py(_attach_watchdog제거·행 흡수) - Tests: tests/application/(행 필드·정본·divergence·overlay 플래그)
Notes
- 수량 정본 모델은 REQ-062(hub 정본 + 슬롯 미러 + 브로커 ground truth)를 그대로 따른다 — 본 REQ 는 그 정본을 행에 표현·라벨하는 계약이다.
- NFR-2(단일 표면·조인 불필요)는 AC-1 에 흡수.
- 출처: dcy-025 FR-3(OQ-2/3).
Change Log
CHG-20260611-01
- Date: 2026-06-11
- Author: Justin Ko
Change Summary
- dcy-025 FR-3(OQ-3 (a)) 로부터 최초 생성(Proposed). 슬롯 단일 행 스키마(자산·워치독·overlay 흡수 + hub 정본/슬롯 미러 둘 다 노출 + 정본 라벨).
Intent
- 병렬 배열 조인 제거 + 필드별 정본 명확화.
Acceptance Criteria Delta
- Added:
- AC-1~5 신규
- Updated/Removed: none
Impacted Area Delta
- Docs: interface-contract/data-model
- Modules: portfolio.py(slot_to_dict)/messaging_handlers.py
- Tests: 행 스키마/divergence/overlay
Delivery Trace Delta
- Batches: none(승인 후 draft-batch)
- Releases: none
Revalidation Impact
- Reverification Needed: no(신규)
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current(Proposed)
- Follow-up Action: confirm-req
Validation Plan
- 신규 batch: 행 필드 단언, qty↔asset_quantity divergence+warned, cash_estimated 수렴, paused holding 직교, strategy 필드 부재.