Files
trex-core/docs/batches/bat-025_20260609_slot-entry-count-and-closed-reallocation/index.md
T
genichinandClaude Opus 4.8 6e8e79660c feat(slot): slot entry_count + closed-slot reallocation (dcy-019, BAT-025) + REL-005
dcy-019/issue #18: slot 자원을 진입 횟수 기준으로 고르게 재사용하고 idle 소진 시
closed 슬롯을 직접 재할당한다. 거버넌스는 전부 change-req(신규 REQ 없음).

- 도메인(REQ-002): Slot.entry_count(기본 0) + EXPECTED_SLOT_FIELDS, 상태 머신
  closed→pending_buy 신규 전이(base 8→9, ALLOWED_TRANSITIONS 14→15),
  _apply_transition_fields closed→pending_buy clean-slate + →pending_buy 시 +1
- 영속화(REQ-006): 멱등 마이그레이션 008(entry_count), flat 매핑,
  find_allocatable_slot(idle∪closed, entry_count→updated_at→slot_id) + in-memory 동등
- admission(REQ-007): _admit_buy find_idle_slot→find_allocatable_slot + from_state=slot.status
- 테스트(REQ-003): 전이 카운트/계약 가드 정합 + test_slot_entry_count.py / test_buy_admission_reallocation.py
- 문서(REQ-009): data-model.md / runtime-flows.md 정합
- 기존 daily_symbol_entries(symbol-scoped) 분리·미변경

BAT-025(release-candidate) delivery + change-req REQ-002/003/006/007/009(CHG-20260609-01).
REL-005(confirmed, app-service): BAT-024+BAT-025 묶음. operator-facing run-the-app
스모크로 enter --forced-close-at(BAT-024)·closed 재할당(BAT-025) 실 데몬 검증
(실 PG 마이그레이션 008 round-trip 포함).

검증: 단위 366 passed / 35 skipped(KIS sandbox 1건 deselect — live .env 환경 의존), ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 14:49:22 +09:00

3.3 KiB
Raw Blame History

BAT-025: slot-scoped entry_count + closed 슬롯 직접 재할당 (dcy-019)

  • Status: release-candidate
  • Profile: standard
  • Source Discovery: dcy-019
  • Included REQ: REQ-002 (CHG-20260609-01), REQ-003 (CHG-20260609-01), REQ-006 (CHG-20260609-01), REQ-007 (CHG-20260609-01), REQ-009 (CHG-20260609-01)

Summary

  • dcy-019(slot 진입 횟수 필드 + idle∪closed 후보 중 최저 진입 우선 선택 + closed 직접 재할당, issue #18)을 단일 standard batch 로 delivery 한다. 거버넌스는 dcy-019 OQ-1/2/3 결정대로 전부 change-req, 신규 REQ 없음.
  • 핵심: daily_slot/Slot 에 slot-scoped entry_count(기본 0) 필드 + 멱등 마이그레이션 008(REQ-002/006), 상태 머신 closed→pending_buy 신규 전이(8→9 base, ALLOWED_TRANSITIONS 14→15)(REQ-002), buy admission 의 후보를 idle∪closed 로 확장하고 entry_count→updated_at→slot_id 결정적 정렬로 선택하는 find_allocatable_slot selector(REQ-006) + _admit_buy 일반화(REQ-007), →pending_buy(idle→/closed→) 시 entry_count +1 및 closed→pending_buy clean-slate 점유 초기화(REQ-002). 기존 daily_symbol_entries(symbol-scoped 재진입 카운터)와 분리·미변경.

Scope

  • In Scope:
    • Slot.entry_count(기본 0) + EXPECTED_SLOT_FIELDS + 멱등 마이그레이션 008 + persistence flat 매핑 (REQ-002/006)
    • 상태 머신 closed→pending_buy 신규 전이 + _apply_transition_fields clean-slate + entry_count +1 (REQ-002)
    • find_allocatable_slot(idle∪closed, entry_count→updated_at→slot_id) selector + in-memory 동등 (REQ-006)
    • _admit_buy find_idle_slot→find_allocatable_slot + from_state=slot.status (REQ-007)
    • 테스트 계약 정합(전이 카운트·필드셋·신규 단위) (REQ-003)
    • data-model/runtime-flows baseline 정합 (REQ-009)
  • Out of Scope:
    • daily_symbol_entries(symbol-scoped 재진입 카운터) 제거/변경 — 별도 REQ-002 change-req 트랙(후속)
    • 운영자 CLI/스냅샷에 slot entry_count 노출 (dcy-019 §5 제외)
    • 슬롯별 PnL 집계, 전략 모듈에 선택 정책 노출, preallocation 총량/스케줄 변경
    • snapshot available_slots(=idle_count) capacity 의미 변경 (dcy-019 범위 밖 — 보수적 under-report 유지)

Documents

Notes

  • Source discovery 단일(dcy-019). OQ-1 (a) daily_slot 단독 / OQ-2 entry_count→updated_at→slot_id / OQ-3 closed→pending_buy 직접 전이·→pending_buy 시 +1 Answered.
  • additive·하위호환(NFR-3): 마이그레이션 008 기본 0, closed 후보 부재 시 기존 idle-only 동작 보존(회귀 green).
  • 동시성(NFR-1): selector find 쿼리는 기존 find_idle_slot 와 동일하게 FOR UPDATE 미사용 — claim 경합은 transit_slot advisory lock + SlotStateMismatchError 재시도 루프로 직렬화(중복 카운트 없음).
  • 신규 slot entry_count 와 daily_symbol_entries.entry_count 는 키·목적이 다른 별개 카운터(R-1) — data-model 에 구분 기록.
  • PG 게이트 마이그레이션/드리프트 테스트는 라이브 runtime DSN 미사용(pg_clean truncate 파괴적) — test DSN 환경에서 자동 검증.