Add dcy-003 (confirmed) + REQ-011~015: broker execution + KIS + outbox

dcy-003 confirmed (all OQ answered, operator-confirmed scope/risk):
- OQ-1: paper/stub + real KIS Open API adapter (validated on KIS paper
  server; live account go-live config-gated, deferred).
- OQ-2: unified async fill (submit -> poll); paper is a deterministic
  async double (no synchronous shortcut) for faithful path coverage.
- OQ-3: option A — pending slot is the execution queue, broker_order_id
  is the idempotency guard; no separate outbox table (option B as a
  growth hook; intent_log stays dedup-only).
- OQ-4: dedicated background execution loop (claim -> submit -> poll ->
  reconcile); intent API only transitions to pending.

Decompose into REQ-011~015 (all Proposed): BrokerPort + paper double,
KIS adapter, execution loop, durability+reconciliation (Exception),
baseline alignment. NFR-1/2/3 absorbed. Update SRS index + dcy-003
created-REQ refs. Safety floor, KIS live account, strategy daemons, and
auth remain deferred to follow-up Discoveries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-04 16:40:23 +09:00
co-authored by Claude Opus 4.8
parent 575ba9f513
commit d60d720bc7
8 changed files with 593 additions and 2 deletions
@@ -0,0 +1,70 @@
# req-014: 주문 핸드오프 durability + reconciliation
- Status: Proposed
- Type: Exception
- Priority: High
- Owner: project maintainers
## Intent
- 집행 도중 크래시가 나도 중복 주문 없이 일관 상태로 복구되도록, 옵션 A(pending 슬롯=실행큐 + broker_order_id 멱등)에 재기동 reconciliation 을 더한다.
## Requirement
- 재기동 시 코어가 `broker_order_id` 가 채워진 pending 슬롯을 브로커 주문 상태와 대조해 reconciliation 한다: 체결됨→해당 전이(holding/closed), 거부/취소됨→롤백(idle), 미체결→계속 poll. `broker_order_id` 가 비어 있는 pending 슬롯은 미송신으로 보고 정상 claim 경로로 재개한다. 동일 슬롯/주문에 대해 중복 주문이 발생하지 않는다.
## Acceptance Criteria
1. Given 주문 송신 후 broker_order_id 기록까지 된 상태에서 크래시, When 재기동 reconciliation, Then 같은 슬롯에 재주문하지 않고 브로커 상태로 전이를 정리한다(중복 주문 0).
2. Given 주문 송신 전(broker_order_id NULL) 크래시, When 재기동, Then 정상 claim 으로 재개해 1회만 송신한다.
3. Given 브로커에서 이미 체결된 주문, When reconciliation, Then 슬롯이 holding/closed 로 수렴한다.
4. Given 동일 집행이 두 번 수행(루프 중복 틱), When 점검, Then broker_order_id 멱등 가드로 중복 주문이 생기지 않는다. (NFR-3)
## Impacted Area
- Docs: docs/runtime-flows.md(reconciliation 흐름) — REQ-015
- Modules: trex_core 집행/복구 컴포넌트(REQ-013 루프에 reconcile 단계), 브로커 주문 상태 조회 재사용
- Tests: 크래시 주입(송신 전/후) 후 reconciliation, 중복 주문 0, 멱등 재틱
## Notes
- 옵션 A 기반(별도 outbox 테이블 없음). 부분체결/재시도 본격화 시 옵션 B 승격은 후속.
- 출처: dcy-003 FR-5, NFR-3. 핵심 안전(R-1) 완화의 실현.
## Change Log
### CHG-20260604-01
- Date: 2026-06-04
- Author: Justin Ko
#### Change Summary
- dcy-003 FR-5 로부터 최초 생성(Proposed). NFR-3 흡수.
#### Intent
- durable 핸드오프 + reconciliation(크래시 복구·멱등) 요구사항을 backlog 로 정규화.
#### Acceptance Criteria Delta
- Added:
- 송신후 크래시 reconciliation, 송신전 크래시 재개, 체결 수렴, 멱등 재틱 4개 기준
- Updated:
- 없음
- Removed:
- 없음
#### Impacted Area Delta
- Docs:
- docs/runtime-flows.md
- Modules:
- 집행/복구 컴포넌트(reconcile)
- Tests:
- 크래시 주입 reconciliation 테스트
#### Delivery Trace Delta
- Batches:
- none
- Releases:
- none
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: confirm-req 후 batch 편성
#### Validation Plan
- 크래시 주입(송신 전/후) reconciliation + 중복 주문 0 테스트로 검증.