전략 이탈로 슬롯이 내부 청산 루틴(워치독) 소유로 넘어간 상태가 무성이라 운영자가 인지할 수 없던 문제(issue #12)를 가시화한다. 거버넌스: 전부 change-req (신규 REQ 없음, dcy-017 OQ-3; Redis 미채택). - REQ-034/021: WatchdogStore.last_seen + snapshot RPC 응답에 holding 슬롯 워치독 상태(expired/last_seen) read-only 동봉(best-effort) - REQ-032: trex-core slots 가 expired 슬롯을 WATCHDOG-OWNED(전략 이탈) 표시 - REQ-037/038/039: safety-sell 워치독 소유 진입(WARN)/이탈(INFO) + 발동 (forced_close·stop_loss=WARN, take_profit·market_close=INFO) 로그 + in-process 카운터(SafetySellService.counters), 구조화 필드(slot_id/ portfolio_id/reason/phase/instance_key). per-tick 스킵은 카운터만 - REQ-042: runtime-flows/interface-contract 정합 best-effort 격리(NFR-1): 모든 가시화는 예외 격리 — 워치독 판정·청산 불변. dcy-016 억제 읽기로 관측이 워치독을 리셋하지 않음(비침습). 검증: 단위 335 passed/34 skipped, 인프라 게이트(PG+RabbitMQ) 369 passed, ruff clean. 신규 test_safety_sell_visibility(6) + snapshot watchdog(1) + CLI(1). BAT-021 rc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6.5 KiB
6.5 KiB
req-042: safety-sell baseline 문서 정합
- Status: Implemented
- Type: Documentation
- Priority: Medium
- Owner: project maintainers
Intent
dcy-007에서 정의된 자율 안전 매도 기능(REQ-034~041)의 구현 완료 후 docs/interface-contract.md, docs/runtime-flows.md, docs/project-structure.md 세 baseline 문서를 최신 아키텍처와 정합시킨다.
Requirement
docs/interface-contract.md에 아래 항목을 반영해야 한다:- intent RPC payload에
stop_loss_price,take_profit_price선택 필드 추가 update_thresholdsaction 계약 (payload 구조, 응답 구조, holding-only 제약)- snapshot RPC가 워치독
last_seen_at갱신 신호임을 명시
- intent RPC payload에
docs/runtime-flows.md에 아래 흐름을 추가해야 한다:per-slot 워치독 갱신흐름 (snapshot RPC handler → last_seen_at 갱신)forced_close_at 만기 자동 매도흐름 (safety-sell worker → forced_close_at 체크 → sell())stop-loss·take-profit 가격 체크흐름 (KIS polling → 조건 평가 → sell())장 마감 강제 청산흐름 (TREX_MARKET_CLOSE_LIQUIDATION_TIME → 전체 holding 매도)runtime-flows.md:114의 "A-5 미구현" 주석을 dcy-007 REQ 목록 참조로 갱신
docs/project-structure.md에 아래 항목을 반영해야 한다:- Primary Runtime 스레드 목록에
trex-safety-sell추가 - 신규 5종 env var(
TREX_WATCHDOG_TIMEOUT등) 목록 추가 - 신규 어댑터/모듈(KIS 현재가 polling, watchdog store) 반영
- Primary Runtime 스레드 목록에
Acceptance Criteria
- Given
docs/interface-contract.md를 읽을 때, Whenupdate_thresholdsaction을 찾으면, Then payload 구조(slot_id,stop_loss_price?,take_profit_price?,forced_close_at?)와 응답(status: updated|ignored)이 명시되어 있다. - Given
docs/interface-contract.md를 읽을 때, When intent RPC payload 예시를 찾으면, Thenstop_loss_price와take_profit_price가 선택 필드로 포함되어 있다. - Given
docs/runtime-flows.md를 읽을 때, When safety-sell 관련 흐름을 찾으면, Then 워치독 갱신·forced_close_at 체크·가격 체크·장 마감 청산 흐름이 각각 서술되어 있다. - Given
docs/runtime-flows.md:114(또는 이에 해당하는 broker degrade 흐름)을 읽을 때, When "A-5 미구현" 주석을 찾으면, Then 해당 주석이 dcy-007 구현 REQ 참조로 갱신되어 있다. - Given
docs/project-structure.md를 읽을 때, When Primary Runtime 스레드 목록을 찾으면, Thentrex-safety-sell이 포함되어 있다.
Impacted Area
- Docs:
docs/interface-contract.mddocs/runtime-flows.mddocs/project-structure.md
- Modules: 없음 (문서 전용)
- Tests: 없음
Notes
- 이 REQ는 REQ-034~041 구현이 완료된 후 실행해야 한다. batch verification 단계에서 최신 구현 상태를 반영해 문서를 갱신한다.
runtime-flows.md:114의 "A-5 미구현" 문구는 dcy-007 confirmed 시점에 이미 근거가 확보됐으므로, 구현 완료 전에도 "dcy-007 REQ-034~041로 트래킹" 형태로 미리 갱신할 수 있다.- NFR-2(outbox retry) 관련 흐름은 기존 runtime-flows.md의 outbox 섹션에 흡수되어 있으므로 별도 추가 불필요.
Change Log
CHG-20260607-01
- Date: 2026-06-07
- Author: Justin Ko
Change Summary
- dcy-007 confirmed → REQ-042 초안 생성
Intent
- safety-sell 구현 후 세 baseline 문서 정합을 Documentation REQ로 정규화
Acceptance Criteria Delta
- Added: AC-1~5 전체
Impacted Area Delta
- Docs: interface-contract.md, runtime-flows.md, project-structure.md
Delivery Trace Delta
- Batches: none (미할당)
- Releases: none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: suggest-batch-reqs 후 batch 배정 (REQ-034~041 구현 batch 이후 연계)
CHG-20260607-02
- Date: 2026-06-07
- Author: Justin Ko
Change Summary
- Proposed → Approved (confirm-req)
Intent
- 승인 게이트 통과: 필수 필드·AC·Impacted Area·Change Log 완비 확인. dcy-007(confirmed) 범위 및 결정 사항과 모순 없음.
Acceptance Criteria Delta
- (변경 없음)
Impacted Area Delta
- (변경 없음)
Delivery Trace Delta
- Batches: none (미할당)
- Releases: none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: suggest-batch-reqs 후 batch 배정
CHG-20260607-03
- Date: 2026-06-07
- Author: Justin Ko
Change Summary
- Status Approved → Implemented (confirm-req-implemented, 근거 batch BAT-011 release-candidate).
Intent
- BAT-011 에서 세 baseline 문서 정합 완료(interface-contract: update_thresholds 계약 + price 선택 필드 + 워치독 신호; runtime-flows: 워치독 갱신/forced_close/가격 체크/장 마감 4종 흐름 + A-5 주석 갱신; project-structure: trex-safety-sell 스레드 + watchdog.py/safety_sell.py 모듈). AC-1~5 충족 → 구현 완료 동기화.
Acceptance Criteria Delta
- (변경 없음)
Impacted Area Delta
- (변경 없음)
Delivery Trace Delta
- Batches: BAT-011 (release-candidate)
- Releases: none
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current (Implemented)
- Follow-up Action: draft-release 로 BAT-011 배포 편성.
CHG-20260608-01
- Date: 2026-06-08
- Author: Justin Ko
Change Summary
- (change-req, dcy-017) baseline 문서를 워치독 가시화에 맞춰 정합:
docs/runtime-flows.md(워치독 상태 노출 + safety-sell 가시화 flow),docs/interface-contract.md(snapshot 응답watchdog필드). BAT-021 정합 완료 → Implemented 유지.
Intent
- 코드(watchdog/messaging_handlers/safety_sell/cli) 변경과 baseline 문서를 일치시켜 운영자 참조 정합 유지.
Acceptance Criteria Delta
- Updated:
- runtime-flows/interface-contract 의 워치독 가시화·safety-sell 발동 가시화 기술 정합.
Impacted Area Delta
- Docs: docs/runtime-flows.md, docs/interface-contract.md
Delivery Trace Delta
- Batches: BAT-021
- Releases: none
Revalidation Impact
- Reverification Needed: no (문서 정합)
- Existing Implementation Invalidated: no
- Status Recommendation: Implemented (change-req → BAT-021 정합)
- Follow-up Action: confirm-req-implemented(BAT-021).
Validation Plan
- BAT-021: 코드-문서 diff 대조.