Files
trex-core/docs/srs/Exception/req-055_ledger-gap-ops-check.md
T
genichinandClaude Opus 4.8 aee3512383 feat(intents): dcy-011 buy intent portfolio_id 필수 계약 + ledger skip 가시화 (BAT-015)
dcy-011 전 주기 delivery. issue #6(buy 식별자 정정) + issue #11(ledger silent skip) 흡수.
거버넌스: 기존 Implemented REQ는 change-req, 신규 기능만 신규 REQ(OQ-3).

- REQ-007 (change-req): buy admission portfolio_id 필수화 + SnapshotStore symbol
  resolve + unknown_portfolio 거부 (hard cutover, OQ-1/OQ-2)
- REQ-021 (change-req): buy 메시지 payload symbol 제거
- REQ-018 (change-req): _record_ledger skip 가시화 (WARN + ledger_skipped 카운터)
- REQ-055 (신규): closed↔ledger_outbox anti-join 운영 점검 find_ledger_gap_slots

코드: intents.py(BuyIntent portfolio_id 필수 + resolve_symbol 주입 + _admit_buy
reject 분기), messaging_handlers.py, runtime/daemon.py(_resolve_symbol 배선),
execution.py(skip WARN 로그), adapters/persistence/ops_checks.py(신규 anti-join).

검증: 단위 282 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 314 passed, ruff clean.
BAT-015(standard) release-candidate. srs/index Next ID → REQ-056.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:57:51 +09:00

3.3 KiB

req-055: closed 슬롯 ↔ ledger_outbox 누락 운영 점검 쿼리

  • Status: Implemented
  • Type: Exception
  • Priority: Medium
  • Owner: project maintainers

Intent

portfolio_id 없는 체결의 ledger silent skip(issue #11)으로 발생하는 회계 누락을 운영자가 탐지·집계할 수 있도록, closed 슬롯 중 대응 ledger_outbox 행이 없는 케이스를 anti-join 으로 식별하는 읽기 전용 운영 점검을 제공한다(dcy-011 FR-5). daily_slot 이 durable 하므로 outbox 마커 행 없이도 영구 탐지가 성립한다(dcy-010 OQ-4 위임).

Requirement

  • find_ledger_gap_slots(dsn, *, trading_date=None) 읽기 전용 함수를 제공한다(trex_core/adapters/persistence/ops_checks.py).
  • gap 정의: status='closed' 슬롯 중 portfolio_id IS NULL 이거나 ledger_outbox 에 asset_id = slot.portfolio_id 행이 없는 슬롯.
  • 결과는 slot_id/trading_date/symbol/portfolio_id/broker_order_id 를 포함한다. trading_date 인자로 일자 범위를 한정할 수 있다(미지정 시 전체).
  • 스키마 변경 없음(읽기 전용 SELECT). 주기/온디맨드 실행으로 누락을 탐지·집계할 수 있어야 한다.

Acceptance Criteria

  1. Given closed 슬롯 중 portfolio_id IS NULL 인 슬롯, When find_ledger_gap_slots, Then 그 슬롯이 결과에 포함된다(S-4).
  2. Given closed 슬롯 중 portfolio_id 는 있으나 대응 outbox 행이 없는 슬롯, When 호출, Then 결과에 포함된다.
  3. Given closed 슬롯 + 대응 ledger_outbox 행(asset_id 일치)이 있는 슬롯, When 호출, Then 결과에 포함되지 않는다(정상 케이스 0건).
  4. Given holding 등 비-closed 슬롯, When 호출, Then 결과에서 제외된다(closed 한정).

Impacted Area

  • Docs: docs/runtime-flows.md(ledger skip 가시화 + 점검 쿼리 참조)
  • Modules: trex_core/adapters/persistence/ops_checks.py(신규, 읽기 전용)
  • Tests: tests/adapters/persistence/test_ops_checks.py(PG 게이트)

Notes

  • OQ-4 결정: outbox 마커 행 미도입 → slots↔outbox anti-join 으로 영구 탐지(REQ-019 outbox 스키마 변경 없음).
  • 알람/주기 실행 연결은 운영 배포 절차로 다룬다(쿼리/함수가 산출물).

Change Log

CHG-20260608-01

  • Date: 2026-06-08
  • Author: Justin Ko

Change Summary

  • dcy-011(confirmed) → REQ-055 생성(draft-req, Proposed). issue #11 제안 ③: closed↔outbox 대조 운영 점검(FR-5). 기존 REQ 가 다루지 않는 신규 기능이라 신규 REQ(OQ-3 결정).

Intent

  • ledger 누락 영구 탐지 수단을 운영자에게 제공.

Acceptance Criteria Delta

  • Added: AC-1~4 전체

Delivery Trace Delta

  • Batches: BAT-015
  • Releases: none

Revalidation Impact

  • Reverification Needed: no
  • Status Recommendation: keep-current

CHG-20260608-02

  • Date: 2026-06-08
  • Author: Justin Ko

Change Summary

  • Proposed → Approved (confirm-req). 필수 필드·구체 AC·dcy-011 FR-5 정합 확인.

CHG-20260608-03

  • Date: 2026-06-08
  • Author: Justin Ko

Change Summary

  • Approved → Implemented (confirm-req-implemented, 근거 BAT-015 release-candidate). find_ledger_gap_slots 구현 + PG 게이트 단위(gap 탐지/정상 0건) green. 전체 인프라 게이트 314 passed.

Delivery Trace Delta

  • Batches: BAT-015 (release-candidate)
  • Releases: none