Files
trex-core/docs/batches/bat-046_20260616_observability-classification-pnl-runbook/implementation.md
T
genichinandClaude Opus 4.8 d8d9021260 feat(execution,obs): 호가단위 스냅(dcy-030/#28) + 운영 관측성(dcy-029/#29) + REL-007 환류
dcy-030 (issue #28, P0 체결 복구):
- REQ-083 KRX 호가단위(tick) 순수 유틸 (domain/pricing.py)
- REQ-070 CHG: 슬리피지 실효가 호가단위 스냅 — 상한 준수(매수 floor/매도 ceil)
  + band<1tick 하한/상한 보장 + 부동소수 epsilon 가드. 147700→148400/54500→54700.
- BAT-044 release-candidate

dcy-029 (issue #29, 운영 관측성):
- REQ-084 구조화 로깅 기반 (runtime/logging_setup.py): ISO8601 KST·레벨·Loki JSON
  ·correlation id(slot_id)
- REQ-085 주문 결과 로깅 (event=order_submit|fill|reject)
- REQ-087 거부 ERROR 가시성 (조용한 롤백 제거)
- REQ-086 청산 reason+actor 동반 노출 (안전망/전략 구분, 신규 필드 없음)
- REQ-088 운영 조회 CLI report (application/operator_report.py, 보유·오늘 체결
  ·실현 PnL net·대기, direct-DB)
- REQ-089 운영자 런북 docs/operations.md
- REQ-090 baseline 정합 (runtime-flows·project-structure·interface-contract)
- BAT-045(P0)·BAT-046(P1) release-candidate

REL-007: confirmed → feedback-captured (운영 인스턴스 라이브 검증 + #28/#29 환류
정규화). BAT-037~041 released.

검증: 537 passed, 47 skipped, 회귀 0, ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 13:19:31 +09:00

2.1 KiB

BAT-046 Implementation

  • Status: completed
  • Batch: BAT-046

Plan Summary

  • 청산 reason+actor 노출(REQ-086) + 운영 조회 CLI(REQ-088) + 운영자 런북(REQ-089) + baseline 정합(REQ-090).

Changed Files

  • trex_core/application/safety_sell.py — _log_fire에 actor=trex-safety-sell 동반 노출(REQ-086).
  • docs/interface-contract.md — 청산 reason+actor 어휘 절 + report CLI 매핑(REQ-086/088).
  • trex_core/application/operator_report.py (신규) — Holding/PendingOrder/TradeRow/OperatorReport, realized_pnl(net), build_report, render_text/render_json, kst_day_bounds_utc(REQ-088).
  • trex_core/runtime/cli.py — report 서브커맨드 + _cmd_report(direct-DB psycopg: daily_slot holdings/pending + ledger_outbox 오늘 체결 → build_report → text/json)(REQ-088).
  • docs/operations.md (신규) — 운영자 런북 4영역(REQ-089).
  • docs/runtime-flows.md·docs/project-structure.md — 로깅/관측성·report flow + 신규 모듈 정합(REQ-090).
  • tests/application/test_operator_report.py (신규) — 집계·net PnL·KST 경계·렌더.
  • tests/application/test_safety_sell_visibility.py — reason+actor 동반 노출 테스트(REQ-086).

Execution Log

  1. operator_report 순수 집계 + 단위 테스트(7) green.
  2. cli report 서브커맨드(direct-DB) 추가.
  3. safety_sell actor 로그 + 테스트.
  4. interface-contract reason+actor 어휘 + report 매핑.
  5. docs/operations.md 런북 작성.
  6. runtime-flows·project-structure 정합, 전체 회귀 + ruff(F841 1건 수정).

Validation

  • pytest tests/application/test_operator_report.py tests/application/test_safety_sell_visibility.py → 14 passed.
  • 전체 pytest -q → 537 passed, 47 skipped, 회귀 0.
  • ruff check trex_core/ tests/ → All checks passed.

Remaining Risks

  • report direct-DB 와이어링은 순수 집계 단위 검증 + 실 DB 검증 release 위임(pause/resume 선례).
  • 실현 PnL은 net 현금흐름 정의(미청산 평가손익·cost-basis 매칭 제외) — 런북·계약 명시.
  • Loki 실 적재는 배포측 수집기.