Files
trex-core/docs/srs/Integration/req-058_universe-slot-reconcile-lifecycle.md
T
genichinandClaude Opus 4.8 f7d309be71 docs(req): dcy-020 confirm-req(REQ-056~065 Approved) + 기존 REQ supersession change-req
- confirm-req: REQ-056~065 Proposed→Approved (CHG-20260610-02 각). srs/index Register Approved.
- change-req(forward-looking): REQ-002/003/005/006/007 에 dcy-020 재정의/폐기 예정 기록
  (CHG-20260610-01). 현재 코드 불변이라 status Implemented 유지(keep-current);
  실제 폐기/재정의·status 전환은 dcy-020 delivery 배치에서 확정.
  - REQ-002 상태머신/도메인 → REQ-056/057/062
  - REQ-003 테스트 계약 → REQ-056/057
  - REQ-005 일일 preallocation 폐기 → REQ-058(reconcile)/REQ-060(M)
  - REQ-006 persistence 스키마 → REQ-056/062/064
  - REQ-007 admission/intent → REQ-059/061

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:32:52 +09:00

4.5 KiB

req-058: universe 기반 슬롯 lifecycle reconcile (생성/soft-retire/tombstone)

  • Status: Approved
  • Type: Integration
  • Priority: High
  • Owner: project maintainers

Intent

  • 슬롯 집합을 portfolio-hub universe 의 projection 으로 유지하기 위해, universe fetch 결과로 슬롯을 생성/은퇴하는 reconcile 경로를 정의한다. 일일 preallocation(dcy-014)을 폐기하고 universe 동기화로 대체한다. (dcy-020 FR-1/OQ-2/NFR-3)

Requirement

  • 스냅샷 refresh(get_portfolios 성공 직후)에 슬롯 reconcile 을 수행한다: (1) universe 신규 자산 → 영구 슬롯 즉시 생성(비활성·멱등, UNIQUE(instance_key, portfolio_id)); (2) universe 제거 + 슬롯 비활성(holding/pending 아님) → soft-retire(retired_at 마킹, 행 보존, hard delete 금지); (3) universe 제거 + 보유 중/pending → tombstone(은퇴 보류, safety-sell/watchdog 유지, 신규 매수 후보 제외, 닫힌 뒤 은퇴). reconcile 쓰기는 인스턴스 스코프 advisory lock 안에서 단일 writer 로 수행한다. cadence 는 기존 부팅 + 일 1회 + 운영자 on-demand. portfolio-hub 불가/degraded 또는 universe N→0/급격 대량 감소면 생성·은퇴를 보류하고 경고한다.

Acceptance Criteria

  1. Given universe 에 신규 자산, When reconcile, Then 그 자산의 영구 슬롯이 비활성으로 생성되고 재실행해도 중복 생성되지 않는다(멱등).
  2. Given universe 에서 빠진 비활성 슬롯, When reconcile, Then soft-retire(retired_at set, 행 보존)되고, 같은 자산이 재등장하면 동일 슬롯이 재활성화된다.
  3. Given universe 에서 빠졌으나 holding/pending 인 슬롯, When reconcile, Then 은퇴되지 않고 tombstone(신규 매수 제외·safety-sell 유지)되며, 매도 체결 후에야 은퇴된다.
  4. Given portfolio-hub degraded 또는 universe 가 N→0, When reconcile, Then 슬롯 생성·은퇴가 보류되고 마지막 집합이 유지되며 경고가 남는다.

Impacted Area

  • Docs: docs/runtime-flows.md(reconcile lifecycle)
  • Modules: trex_core/application/snapshot_scheduler.py, trex_core/domain/slot/repository.py, trex_core/adapters/persistence/postgresql.py, trex_core/application/preallocation_scheduler.py(폐기)
  • Tests: tests/application/test_snapshot_scheduler.py(reconcile), tests/application/test_preallocation_scheduler.py(폐기/대체)

Notes

  • 기존 REQ-005/REQ-048(일일 preallocation·instance config) change-req 동반(preallocation 폐기·재해석). trading_date KST 계산(REQ-005)은 일일 회계 경계용으로 부분 존속.
  • 출처: dcy-020 FR-1, OQ-2, NFR-3.

Change Log

CHG-20260610-01

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

Change Summary

  • dcy-020 FR-1/OQ-2/NFR-3 로부터 최초 생성(Proposed). universe reconcile(생성/soft-retire/tombstone) + degrade·대량소멸 보류 + 일일 preallocation 폐기.

Intent

  • 슬롯 집합을 universe projection 으로 유지하는 lifecycle 을 backlog 로 정규화.

Acceptance Criteria Delta

  • Added:
    • 생성 멱등/비활성 soft-retire 재활성/tombstone/degrade·대량소멸 보류 4개 기준
  • Updated: 없음
  • Removed: 없음

Impacted Area Delta

  • Docs: docs/runtime-flows.md
  • Modules: snapshot_scheduler.py, repository.py, postgresql.py, preallocation_scheduler.py(폐기)
  • Tests: test_snapshot_scheduler.py, test_preallocation_scheduler.py

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. REQ-005/048 change-req(preallocation 폐기) 동반.

Validation Plan

  • reconcile 생성/은퇴/tombstone/degrade 단위·통합 테스트 green.

CHG-20260610-02

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

Change Summary

  • Status Proposed → Approved (confirm-req). 필수 필드·구체 AC 충족, source dcy-020(confirmed, handoff 승인)과 모순 없음.

Intent

  • delivery input 으로 승격.

Acceptance Criteria Delta

  • Added: 없음 / Updated: 없음 / Removed: 없음

Impacted Area Delta

  • Docs: docs/srs/index.md (Register Approved) / Modules: 없음 / Tests: 없음

Delivery Trace Delta

  • Batches: none / Releases: none

Revalidation Impact

  • Reverification Needed: no / Existing Implementation Invalidated: no / Status Recommendation: keep-current / Follow-up Action: suggest-batch-reqs / draft-batch.

Validation Plan

  • 승인 후 batch planning 에서 본 REQ AC 를 검증 기준으로 사용.