Files
trex-core/.proofline/lines/line-0007/req-0007.md
T

5.3 KiB

id, status, discovery, criteria
id status discovery criteria
req-0007 approved dcy-0007
create update retire satisfy
ac-0024

Reconciliation 수량 불일치 알림

Objective

trex-core가 B-case(core slot↔broker)와 C-case(portfolio-hub symbol aggregate↔broker) 수량 불일치의 최초 탐지, material quantity change와 authoritative resolution을 중복 폭주 없이 trex.alerts에 발행하게 한다. 알림 lifecycle은 process restart 뒤에도 이어지고 publish 실패는 다음 detection에서 재시도할 수 있어야 하며, reconciliation·warning·slot·broker·portfolio-hub의 기존 동작과 권한을 중단하거나 변경하지 않는다.

Scope

  • B-case mismatch는 stable slot identity별로 추적하고, C-case mismatch는 instance_key + symbol별로 추적한다. C-case의 동일 symbol에 여러 portfolio/slot이 있어도 하나의 aggregate mismatch lifecycle로 취급한다.
  • B-case 비교 quantity tuple은 core slot quantity와 broker quantity이고, C-case 비교 quantity tuple은 같은 instance·symbol의 portfolio-hub asset_quantity 합계와 broker quantity다.
  • 이전에 성공적으로 알린 fingerprint가 없는 active mismatch는 detected event를 발행한다. 같은 identity와 같은 quantity tuple의 scheduler 반복 탐지는 event를 재발행하지 않는다.
  • active mismatch의 case별 quantity tuple이 바뀌면 changed event를 한 번 발행하고 성공한 새 fingerprint를 durable하게 보존한다.
  • B-case recovery/resolved event는 operator sync가 broker-authoritative quantity로 warning을 clear하는 경로에서만 발행한다. C-case recovery/resolved event는 operator verify가 instance_key + symbol aggregate 일치를 재검증하고 C-case warning을 clear하는 경로에서만 발행한다.
  • scheduler가 일치 quantity를 관찰하거나 process-local warning을 clear하는 것만으로 durable warning을 자동 clear하거나 recovery event를 발행하지 않는다.
  • detected·changed·resolved event는 lifecycle state를 구분하고 instance_key, symbol, case_code, broker quantity 및 case별 비교 quantity를 포함한다. B-case identity에는 stable slot identifier를 포함할 수 있으나 account number/hash, credential, token, DSN, raw external payload 또는 exception 본문은 포함하지 않는다.
  • successful publish 뒤에만 해당 lifecycle fingerprint를 durable하게 기록한다. detected/changed publish가 실패하면 다음 동일 detection에서 재시도한다. resolved publish가 실패해도 warning clear는 진행하며, notification state가 writable이면 pending resolved transition을 보존하여 후속 retry opportunity에서 재시도한다.
  • 기존 AlarmEmitter와 trex.alerts envelope·routing contract를 재사용하고 새 event가 trex-notifier의 기존 alarm 소비 경계에 도달하게 한다.
  • B/C 최초 탐지, C-case 다중 portfolio 단일 event, unchanged suppression, quantity change, restart, B sync resolution, C verify resolution, publish failure retry와 sensitive field 부재를 repository-local automated tests로 검증한다.

Constraints

  • AC-0023의 C-case instance_key + symbol aggregate 판정, strategy RPC 제외, intent 차단, C-case-only clear와 operator authority를 완화하거나 대체하지 않는다.
  • B/C warning의 case_code, mismatch 판정식, slot lifecycle 및 broker/portfolio-hub quantity는 알림을 위해 변경하지 않는다.
  • notification state는 restart-safe하고 replay-safe한 persistence로 관리해야 하며 기존 migration runner의 반복 적용을 견뎌야 한다.
  • publish success와 durable fingerprint write 사이의 failure window에서는 at-least-once delivery에 따른 duplicate가 가능하지만, fingerprint를 publish 시도 전에 기록하여 event를 영구 유실시키는 방식은 허용하지 않는다.
  • alarm publish 및 notification-state persistence failure는 reconciliation, warning set/clear, operator sync/verify와 scheduler를 abort시키지 않는 best-effort 경계여야 한다. resolved publish가 실패하고 notification state가 writable이면 pending transition을 보존하지만, notification-state persistence 자체가 실패하면 authoritative warning clear를 되돌리거나 지연하지 않으며 해당 event 유실 가능성을 sanitized log로 남긴다.
  • 기존 alarm consumer와 wire compatibility를 유지하며 RabbitMQ topology 또는 trex-notifier message rendering 변경을 요구하지 않는다.
  • credential, account 식별정보, token, DSN 및 raw KIS/portfolio-hub payload를 test fixture, event, log 또는 evidence에 기록하지 않는다.
  • Normative Design Documents: 없음. 이 REQ와 AC-0024가 normative specification을 소유한다.

Non-Goals

  • B/C mismatch 판정, warning persistence·blocking·clear policy 또는 AC-0023 수정
  • scheduler 관찰에 의한 automatic warning clear 또는 recovery 발행
  • broker/core/portfolio-hub quantity 자동 보정과 operator sync/verify 승인 절차 변경
  • A-case broker-flat 및 기존 alarm inventory의 semantics 변경
  • trex-notifier의 Telegram routing·rendering 구현, RabbitMQ topology 변경과 production delivery 검증
  • live credential·account·database·RabbitMQ·portfolio-hub 연결, production migration, deployment, release 또는 issue closure