From 002340e5fdbee2f33cf8a2c2d5260f16d0b96cf3 Mon Sep 17 00:00:00 2001 From: Justin Ko Date: Thu, 11 Jun 2026 19:01:59 +0900 Subject: [PATCH] =?UTF-8?q?docs(rel-006):=20BAT-035/036=20=ED=8F=AC?= =?UTF-8?q?=ED=95=A8=20+=20=EB=B0=B0=ED=8F=AC=20=EA=B7=BC=EA=B1=B0=20?= =?UTF-8?q?=EB=B3=B4=EC=99=84=20=E2=80=94=20confirmed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BAT-035/036 batch index: confirmed → release-candidate - rel-006: BAT-035/036 추가, status confirmed, SHA 명시, smoke 한계·외부 소비자 분석 기술 - daemon.py: stale 주석 trex.snapshot.req → trex.slots.req Co-Authored-By: Claude Sonnet 4.6 --- .../index.md | 2 +- .../index.md | 2 +- docs/releases/index.md | 2 +- ...1_asset-centric-sizing-execution-policy.md | 25 ++++++++++++++----- trex_core/runtime/daemon.py | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/batches/bat-035_20260611_strategy-read-surface-slots-req/index.md b/docs/batches/bat-035_20260611_strategy-read-surface-slots-req/index.md index 7bcff12..9978841 100644 --- a/docs/batches/bat-035_20260611_strategy-read-surface-slots-req/index.md +++ b/docs/batches/bat-035_20260611_strategy-read-surface-slots-req/index.md @@ -1,6 +1,6 @@ # BAT-035: 전략 read 표면 재설계 — trex.slots.req + 슬롯 단일 행 스키마 (dcy-025) -- Status: confirmed +- Status: release-candidate - Profile: standard - Source Discovery: dcy-025 - Included REQ: REQ-073, REQ-074, REQ-075, REQ-021 (CHG-20260611-01), REQ-034 (CHG-20260611-01), REQ-063 (CHG-20260611-01) diff --git a/docs/batches/bat-036_20260611_safety-sell-disable-mode/index.md b/docs/batches/bat-036_20260611_safety-sell-disable-mode/index.md index 70c3327..d627b50 100644 --- a/docs/batches/bat-036_20260611_safety-sell-disable-mode/index.md +++ b/docs/batches/bat-036_20260611_safety-sell-disable-mode/index.md @@ -1,6 +1,6 @@ # BAT-036: safety_sell_enabled TOML 설정 + 조건부 데몬 워커 기동 (dcy-024) -- Status: confirmed +- Status: release-candidate - Profile: standard - Source Discovery: dcy-024 - Included REQ: REQ-048 (CHG-20260611-01), REQ-005 (CHG-20260611-01) diff --git a/docs/releases/index.md b/docs/releases/index.md index 8cfc84a..867e63e 100644 --- a/docs/releases/index.md +++ b/docs/releases/index.md @@ -13,4 +13,4 @@ | REL-003 | app-service | feedback-captured | BAT-010, BAT-011, BAT-012, BAT-013 | dcy-007 (자율 안전 매도) + dcy-008 (kill-switch) + dcy-009 (다중 인스턴스 토폴로지) — 통합 릴리즈 | [rel-003](rel-003_20260607_safety-killswitch-multi-instance.md) | | REL-004 | app-service | feedback-captured | BAT-014, BAT-015, BAT-016, BAT-017, BAT-018, BAT-019, BAT-020, BAT-021, BAT-022, BAT-023 | dcy-010 (safety-sell 쿨다운) + dcy-011~017 (buy/sell 계약·KIS 취소·trading_date TZ·ledger 백오프 버그픽스 + 운영자 CLI + 워치독 가시화) + dcy-016 후속(슬롯 상태 가시화) + dcy-018 (ledger 현금/포지션 write-back, option D) — 통합 릴리즈 | [rel-004](rel-004_20260608_safety-cooldown-bugfix-hardening-cli.md) | | REL-005 | app-service | feedback-captured | BAT-024, BAT-025 | dcy-016 후속/issue #17 (operator enter --forced-close-at) + dcy-019/issue #18 (slot entry_count + closed 슬롯 재할당) — 통합 릴리즈 | [rel-005](rel-005_20260609_operator-forced-close-and-slot-reallocation.md) | -| REL-006 | app-service | confirmed | BAT-026, BAT-027, BAT-028, BAT-029, BAT-030, BAT-031, BAT-032, BAT-033, BAT-034 | dcy-020 (자산 중심 영구 슬롯 α~δ cutover) + dcy-021 (포지션 사이징/issue #1·#5) + dcy-022 (실행 정책/issue #21) + dcy-023 (allocated_capital 제거/issue #22) + REQ-048·010 CHG (config-dir) + REQ-032 CHG (enter --qty/issue #23) — 통합 릴리즈 | [rel-006](rel-006_20260611_asset-centric-sizing-execution-policy.md) | +| REL-006 | app-service | confirmed | BAT-026, BAT-027, BAT-028, BAT-029, BAT-030, BAT-031, BAT-032, BAT-033, BAT-034, BAT-035, BAT-036 | dcy-020 (자산 중심 영구 슬롯 α~δ cutover) + dcy-021 (포지션 사이징/issue #1·#5) + dcy-022 (실행 정책/issue #21) + dcy-023 (allocated_capital 제거/issue #22) + dcy-024 (safety_sell_enabled/issue #15) + dcy-025 (slots.req 교체·REQ-028 Deprecated) + REQ-048·010 CHG (config-dir) + REQ-032 CHG (enter --qty/issue #23) — 통합 릴리즈 | [rel-006](rel-006_20260611_asset-centric-sizing-execution-policy.md) | diff --git a/docs/releases/rel-006_20260611_asset-centric-sizing-execution-policy.md b/docs/releases/rel-006_20260611_asset-centric-sizing-execution-policy.md index 5efd27d..10bce8e 100644 --- a/docs/releases/rel-006_20260611_asset-centric-sizing-execution-policy.md +++ b/docs/releases/rel-006_20260611_asset-centric-sizing-execution-policy.md @@ -2,7 +2,7 @@ - Status: confirmed - Profile: app-service -- Included Batch: BAT-026, BAT-027, BAT-028, BAT-029, BAT-030, BAT-031, BAT-032, BAT-033, BAT-034 +- Included Batch: BAT-026, BAT-027, BAT-028, BAT-029, BAT-030, BAT-031, BAT-032, BAT-033, BAT-034, BAT-035, BAT-036 ## Scope - Included: @@ -15,23 +15,32 @@ - BAT-032 (dcy-022 / REQ-068~072 + 013·061 CHG): 주문 실행 정책 — intent `timeout_sec`(미체결 자동 취소·cancel-fill race 처리)·`slippage_pct`(보호 지정가 buy ceil/sell floor), per-instance TOML `default_order_timeout_sec`, 운영자 `trex-core cancel` 백스톱. 마이그레이션 012(execution policy 필드). - BAT-033 (batch-lite / REQ-032 CHG-06, issue #23): `trex-core enter` `--qty` 필수 검증 — 미지정 시 RPC 전 즉시 오류(0주 주문 silent 실패 제거). - BAT-034 (dcy-023 / REQ-002·006·007·028·032 CHG, issue #22): 죽은 필드 `allocated_capital` 전 경로 제거 — CLI `--capital` argparse 거부, BuyIntent·payload 수신 무시, Slot/`EXPECTED_SLOT_FIELDS`, snapshot `slots[]`. 마이그레이션 013(컬럼 DROP, 비가역). + - BAT-035 (dcy-025 / REQ-073·074·075 신규 + REQ-021·034·063 CHG): `trex.snapshot.req` → `trex.slots.req` 즉시 교체 — 요청 `{filter: all|inactive|pending|holding|error, spy: bool}`, 응답 `{slots[], degraded, reason, message}`. 슬롯 단일 행 스키마: `asset_quantity`(hub 정본)·`qty`(slot 미러)·`warned`·`cash_balance`·`cash_estimated`·`watchdog{expired,last_seen}`·`paused`; strategy 필드 제외. `spy=true` → watchdog 무터치. REQ-028(`build_snapshot_envelope`/`View`/`SnapshotEnvelope`) Deprecated + 코드 삭제. + - BAT-036 (dcy-024 / REQ-048·005 CHG, issue #15): per-instance TOML `safety_sell_enabled: bool = True` — `false` 시 `trex-safety-sell` 워커 미기동·물리 차단 + `no autonomous liquidation` WARNING 로그. `ExecutionService`·kill-switch·전략 sell intent 불변. - Excluded: - BAT-001~025 (REL-001~005 에서 released) - trex-orb-v1 등 외부 전략 모듈 저장소 변경(발신 계약 전환·allocated_capital 송신 정리 — 별도 합의) - `daily_symbol_entries` 잔재 제거(REL-005 환류 — 별도 change-req 트랙) ## Rollout Plan -1. 배포 전: 거래 세션 외 시간 확보, 현재 운영 리비전 SHA 기록, 본 릴리즈 작업 트리를 main 에 커밋해 배포 SHA 확정. + +- **배포 대상 커밋**: `f0ad37747b4e9d43dc798bfeda5b543cab048890` (main, 2026-06-11) + +1. 배포 전: 거래 세션 외 시간 확보, 현재 운영 리비전 SHA 기록, 위 배포 SHA(`f0ad377`) 확인. 2. **DB 백업(필수)**: 마이그레이션 011·013 은 비가역 컬럼 DROP — 적용 전 운영 `daily_slot`(권장: DB 전체) 백업. BAT-030 design §4 절차 준용. 3. 신 리비전 배포 + 데몬 재기동. `apply_migrations` 가 009~013 자동 적용(전부 멱등). 기동 로그에서 마이그레이션 적용·RUNNING·비-degraded 확인. 4. **cutover 확인**: daily preallocation 부재가 정상 — 영구 자산 슬롯은 snapshot scheduler 의 universe reconcile 이 생성/retire 한다. 기동 직후 universe fetch → 슬롯 생성 로그 확인, `trex-core slots` 로 자산 수 = 슬롯 수 확인. 5. 운영자 CLI 스모크(paper 또는 비거래 시간): - - `trex-core slots` — inactive/holding 상태와 universe_detached 표기 (BAT-027~030) + - `trex-core slots` — 응답 형식 `{slots[], degraded, reason, message}` 확인 (BAT-035: 구 `{assets[], available_slots}` 형식 부재); inactive/holding 상태·universe_detached 표기 (BAT-027~030) + - `trex-core slots --status holding` → `filter=holding` 서버 필터 작동 확인 (BAT-035 filter) + - `trex-core universe` → `trex.slots.req` 큐 사용, spy=true 확인 (BAT-035) - `trex-core enter --yes` → `--qty` 누락 즉시 오류 (BAT-033); `--qty N --yes` → admitted (BAT-029 자산 키) - `trex-core enter ... --capital ...` → argparse 거부 (BAT-034) - 증액/부분 매도 intent e2e (BAT-031), timeout_sec/slippage_pct intent + `trex-core cancel` (BAT-032) -6. 전략 모듈(trex-orb-v1) 재연결 후 buy intent 정상 admit 확인 — `allocated_capital` 송신 잔존은 unknown key 로 무시되어 무해. -7. 거래 세션 재개. +6. **BAT-035 외부 소비자 없음 확인**: `trex.snapshot.req` 구독자는 운영자 CLI 전용이며 CLI 는 이미 `trex.slots.req` 로 갱신됨. 전략 모듈(trex-orb-v1)은 `trex.intent.req` 생산자만이고 snapshot 소비자가 아니므로 차단 없음. +7. 전략 모듈(trex-orb-v1) 재연결 후 buy intent 정상 admit 확인 — `allocated_capital` 송신 잔존은 unknown key 로 무시되어 무해. +8. **BAT-036 확인(해당 시)**: TOML 에 `safety_sell_enabled = false` 설정 시 데몬 기동 로그에 `no autonomous liquidation` WARNING 출력·`trex-safety-sell` 워커 미기동 확인. 기본값 `true` 유지 시 변화 없음. +9. 거래 세션 재개. ## Rollback Plan - 조건: 기동 실패, 마이그레이션 오류, universe reconcile 슬롯 생성 실패(전 자산 미생성), buy admission 회귀, 집행 루프(timeout/slippage) 오작동, CLI 회귀. @@ -47,7 +56,9 @@ - BAT-032 (dcy-022): 425 passed(신규 71 tests — policy lifecycle·timeout·slippage·cancel), 회귀 없음 - BAT-033: 426 passed (AC-7 `--qty` guard + 기존 enter 회귀 보완) - BAT-034 (dcy-023): 428 passed + PG 게이트 21 passed + ruff clean, 마이그레이션 013 테스트 DSN 멱등 round-trip + 컬럼 부재, `grep allocated_capital` 전수 0건 - - SRS: 포함 REQ 전부 Implemented(Approved/Proposed 0건), batch register 9건 release-candidate + - BAT-035 (dcy-025): 420 passed / 45 skipped — `test_slots_handler.py` 신규 13 cases(REQ-073 AC-1~5·REQ-074 AC-1~5 망라), 삭제 4 files(snapshot_handler/snapshot_selection/snapshot_rpc_watchdog/messaging_snapshot_consumer), ruff clean, REQ-028 코드 전수 제거 확인 + - BAT-036 (dcy-024): 420 passed / 45 skipped — `test_instance_config.py` 신규 3 cases(default True·false toml·true toml), ruff clean + - SRS: 포함 REQ 전부 Implemented(Approved/Proposed 0건), batch register 11건 release-candidate - 배포 후 (app-service profile): - 데몬 RUNNING + 비-degraded, 마이그레이션 009~013 적용 로그, 백그라운드 스레드(snapshot scheduler·execution loop) 기동 - universe reconcile 슬롯 생성: 자산 수 = 슬롯 수, retire/tombstone 동작 @@ -69,6 +80,8 @@ confirm-release 전 run-the-app 증거 (2026-06-11, `run-trex-core-daemon` 프 - **DB 계약 (마이그레이션 009~013) — PASS**: `daily_slot` 에 `trading_date`/`entry_count`(011)·`allocated_capital`(013) 컬럼 **부재** 확인. `ledger_outbox` 5행 전부 `completed`. - 종료: SIGTERM → `Normal shutdown`, 에러/traceback 0건(로그의 error-매칭 라인은 전부 pika INFO). - **한계(운영 배포 검증으로 이월)**: LIVE KIS 주문 미검증(paper 한정), portfolio-hub stub(실 universe/ledger 연동은 배포 후 확인), timeout_sec/slippage_pct 정책 발화는 전략 intent 필드라 CLI 미노출 — BAT-032 단위(71 tests) evidence 로 갈음하고 배포 후 전략 모듈 경유로 확인. +- **BAT-035 (`trex.slots.req` 교체) — 단위 검증 갈음**: Pre-release 실 데몬 smoke 는 BAT-026~034 범위로 수행됐으며 BAT-035 라이브 RPC 응답은 미확인. 갈음 근거: `test_slots_handler.py` 13 cases(REQ-073 AC-1~5·REQ-074 AC-1~5) + `test_cli_operator.py` slots queue/spy=true 경로 + `test_topology.py` 상수 교체 전수. 외부 소비자 분석: `trex.snapshot.req` 구독은 운영자 CLI 전용이고 CLI 는 이미 갱신됨 — 차단 없음. 배포 후 첫 `trex-core slots` 호출로 즉시 확인 가능(Rollout 5단계). +- **BAT-036 (`safety_sell_enabled`) — 단위 검증 갈음**: `safety_sell_enabled=false` 라이브 데몬 smoke 미수행. 갈음 근거: `test_instance_config.py` 3 cases(default·false·true toml 경로) + `daemon.py` 코드 경로 검토. 기본값 `true` 유지 시 배포 직후 동작 변화 없음 — `false` 설정은 운영자 명시적 TOML 변경 시에만 활성화되므로 위험도 낮음. ## Release Execution Evidence - Release Status Transition Target: released diff --git a/trex_core/runtime/daemon.py b/trex_core/runtime/daemon.py index a5a7c89..9dc373c 100644 --- a/trex_core/runtime/daemon.py +++ b/trex_core/runtime/daemon.py @@ -5,7 +5,7 @@ strategy-facing communication runs over RabbitMQ (REQ-021/022/023). Threads (started in `run()`): - intent RPC consumer — `trex.intent.req`, prefetch=1, FIFO, dedup via intent_log - - snapshot RPC consumer — `trex.snapshot.req` (also refreshes the watchdog) + - slots RPC consumer — `trex.slots.req` (also refreshes the watchdog; BAT-035/REQ-073) - control RPC consumer — `trex.control.req` (pause/resume/list + kill_switch/resume_kill_switch, REQ-032/043) - execution loop — broker dispatch + poll + slot transitions + event emit - ledger writer — ledger outbox drain (REQ-019)