Deliver BAT-002: slot-core daemon + HTTP intent API + PostgreSQL
Implement REQ-005~009 (dcy-002 slice 1) as an onion stack on top of the
BAT-001 pure domain:
- application: IntentService (admission + single-writer transition +
intent_id idempotency via durable intent_log)
- adapters/persistence: PostgreSQLSlotRepository + PostgreSQLIntentStore +
trex-core-owned migrations (daily_slot per Appendix A, daily_symbol_entries,
slot_transition_log, intent_log) + in-memory intent store
- adapters/api: FastAPI /v1 (healthz, intents/buy|sell|{id}, slots, capacity)
- runtime: trex-core-daemon entrypoint with lifespan migrate+preallocate
Verification (against local PostgreSQL 18): 74 passed, ruff clean, domain
import sweep shows zero web/db deps (NFR-1), 20-thread concurrency admits
exactly the idle count (NFR-2), idempotent resubmit causes no double
transition (NFR-3), EXPECTED_SLOT_FIELDS<->information_schema drift test
(realizes dcy-001 OQ-2's deferred DB-side check), and a daemon E2E smoke.
Align all four baseline docs to the new daemon/API/persistence layers.
BAT-002 -> release-candidate; REQ-005~009 -> Implemented. Full async outbox,
broker execution, safety floor, and strategy daemons remain deferred to a
follow-up Discovery.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
-1
@@ -14,7 +14,7 @@
|
||||
- 자동매매 일일 거래 슬롯 생명주기 도메인 (equity trading slot lifecycle)
|
||||
|
||||
## Primary Persistence Backend
|
||||
- storage-agnostic (SlotRepository Protocol 경유) — 현재 in-memory, 향후 PostgreSQL 예정
|
||||
- PostgreSQL (BAT-002, REQ-006) — 코어 데몬의 durable 단일 writer. 도메인은 여전히 storage-agnostic(SlotRepository Protocol); in-memory 어댑터는 테스트용으로 잔존. 슬라이스 1 테이블: daily_slot / daily_symbol_entries / slot_transition_log / intent_log (daily_slot_archive·prune 은 범위 밖).
|
||||
|
||||
## Purpose
|
||||
- This document captures the approved cross-cutting data model baseline for the project.
|
||||
@@ -86,6 +86,25 @@
|
||||
|
||||
- 오직 INSERT 만 허용한다(append-only).
|
||||
|
||||
## Entity: `intent_log` (BAT-002)
|
||||
|
||||
- Purpose: HTTP 로 제출된 buy/sell intent 의 멱등 dedup 게이트 + audit. `intent_id` UNIQUE 가 at-least-once 재전송의 슬롯 중복 전이를 차단한다(dcy-002 OQ-1).
|
||||
- Source of Truth: intent_log (PostgreSQL) / 테스트는 in-memory IntentStore
|
||||
- Lifecycle: processing -> admitted | rejected
|
||||
|
||||
### Key Fields
|
||||
- intent_id :: TEXT PK :: 멱등키(전략 데몬 발급)
|
||||
- intent_type :: TEXT :: buy | sell
|
||||
- payload :: JSONB :: 제출 본문 스냅샷
|
||||
- status :: TEXT :: processing/admitted/rejected
|
||||
- slot_id :: UUID? :: 수락 시 전이된 슬롯
|
||||
- reason :: TEXT? :: 거부 사유
|
||||
- created_at / updated_at :: TIMESTAMPTZ
|
||||
|
||||
### State Rules
|
||||
- `try_insert` 는 INSERT ... ON CONFLICT DO NOTHING(dedup 게이트). 중복 intent_id 는 재전이 없이 기존 decision 반환.
|
||||
- 완전 비동기 outbox(상태머신 + 소비 루프)로의 승격은 브로커 집행 Discovery 로 Deferred(이 테이블이 전구체).
|
||||
|
||||
## Shared Consistency Rules
|
||||
|
||||
- (trading_date, symbol) 재진입 카운트는 closed->idle 복구와 원자적으로 증가한다.
|
||||
@@ -113,3 +132,4 @@
|
||||
## Change Log
|
||||
|
||||
- 2026-06-03 :: bootstrap-baseline 으로 초기 데이터 모델 baseline 생성(Slot + SlotTransitionRecord + 재진입 카운터).
|
||||
- 2026-06-03 :: BAT-002 — PostgreSQL 영속화 확정 + `intent_log` 엔티티 추가(REQ-006/007/009).
|
||||
|
||||
Reference in New Issue
Block a user