Commit Graph
88 Commits
Author SHA1 Message Date
genichinandClaude Opus 4.8 5330f32247 docs(batch): BAT-030 verification 승인 + REQ-056~065 Implemented (dcy-020 delivery 완료)
draft/confirm-batch-verification: BAT-030 AC 매핑(REQ-056·057·062·064·065) +
evidence(단위 367/PG 29/MQ 21, cutover 리허설 8건, run-the-app e2e) 기록,
Ready for Release: true → release-candidate 승격.
BAT-027/028/029 의 보류 사유(dcy-020 전체 delivery 미완)가 BAT-030 완성으로
해소되어 함께 release-candidate 승격.
confirm-req-implemented: REQ-056~065 전부 Approved → Implemented
(각 REQ Change Log CHG-20260610-IMPL + srs index 갱신).
실 운영 cutover(REQ-064)는 REL 단계 운영자 실행으로 위임.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:20:52 +09:00
genichinandClaude Opus 4.8 7d727824dc feat(slot): BAT-030 — 자산 중심 cutover 완성 (dcy-020 BAT-δ, REQ-056·057·062·064·065)
M1 literal inactive 전면화: SlotState 5-state(idle/closed 별칭 제거),
마이그레이션 010(CHECK 교체+행 rewrite), ops_checks 를 transition_log 기반 재작성.
M2 집행 매도 수량 브로커 정본(D3): dispatch 매도 qty=broker hldg_qty,
미러 fallback 없음, 브로커 0 → skip+WARN, 리스트 기반 dispatch(head-block 방지).
M3 컬럼 drop + legacy pool 제거: 마이그레이션 011(trading_date·entry_count DROP),
repo 계약 instance 스코프 개편(집행 큐 포함), preallocation 폐기(데몬 7스레드),
admission 자산 중심 단일 경로(slot_id 정본), capacity 재정의(available=M−active),
daily_symbol_entries 코드 경로 제거.
M4 cutover 도구(D1·D4): trex-core-cutover(전체 rebuild, preflight/브로커 carry-over/
--allow-unmapped/--promote-unique/dry-run) + PG 리허설 테스트 8건.
M5 baseline 마감: data-model/runtime-flows/project-structure/interface-contract
자산 중심 최종 갱신 + run-trex-core-daemon 스킬 정합.

검증: 단위 367 passed + ruff clean; PG-gated 29 passed(010/011 round-trip·드리프트
가드·cutover 리허설); RabbitMQ 21 passed; run-the-app e2e(test DB+실 MQ, M=1):
reconcile 슬롯 생성→slot_id 매수→dedup→capacity_full→fill→already_active→
매도→inactive(자산 바인딩 보존)→영구 슬롯 재활성 전 구간 green.
실 cutover 는 운영자 실행(REL 단계, D4).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:16:15 +09:00
genichinandClaude Opus 4.8 cec34be5f4 docs(batch): draft-batch BAT-030 (dcy-020 BAT-δ cutover) + design 확정
dcy-020 최종 배치. design 확정(사용자 결정):
- D1: 전체 rebuild — daily_slot 비우고 universe+브로커 잔고 기준 재생성,
  보유 carry-over 정본=브로커 잔고
- D2: 전부 완성 — literal inactive 전면화 + idle/closed 별칭 제거 +
  entry_count/trading_date 컬럼 drop
- D3: 집행 매도 수량 브로커 정본(미러 fallback 없음, 0이면 skip+divergence)
- D4: 실 cutover 는 운영자(REL 단계, 리허설 후); 본 배치는 스크립트+코드+test DB 리허설
batches/index BAT-030 등록.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:36:09 +09:00
genichinandClaude Opus 4.8 78a743a2ef feat(slot): BAT-029 M2(a)/M3 — holding 불일치 reconcile + slots 단일 뷰 (dcy-020/REQ-062·063)
- REQ-062 divergence: list_holding_slots(protocol+in_memory+PG) +
  reconcile_core_holdings(A=코어 holding/broker0→error, C=수량 불일치→warning,
  B=broker 보유/코어 없음→warning; 자동 청산 없음 issue #15). snapshot_scheduler
  자산 중심 모드에서 best-effort 호출, daemon slot_service 배선.
- REQ-063: slot_to_dict 에 universe_detached(retired_at) 추가 — slots 단일 뷰 tombstone 표시.
- 신규 테스트: test_holding_divergence(4).

M2(b) 청산 수량 브로커 정본(execution dispatch)은 라이브 집행 변경 → BAT-δ carry-over.

검증: 단위 393 passed / 36 skipped, PG-gated 18 passed, ruff clean. legacy 무파손.
REQ-061/062/063 Approved 유지(γ 경로 도입 검증; default 전환·M2(b) 는 BAT-δ).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:18:56 +09:00
genichinandClaude Opus 4.8 b80407098e feat(slot): BAT-029 M1 — intent 계약 키 slot_id 통일 (dcy-020/REQ-061)
매수 계약 키를 portfolio_id → slot_id 로 이동(매도는 이미 slot_id). 외부 전략
무중단 위해 portfolio_id 레거시 dual-accept.

- BuyIntent: slot_id 필드 추가, portfolio_id Optional 완화
- _admit_buy: 자산 중심 모드 우선 분기; _admit_buy_asset_centric 가 slot_id(canonical)
  또는 portfolio_id(legacy dual-accept)로 슬롯 해소, symbol 은 슬롯 portfolio_id 로 resolve.
  unknown_slot/unknown_portfolio 사유 구분.
- messaging_handlers: buy 파싱에 slot_id 수용
- 신규 테스트: slot_id 매수 / unknown_slot / 기존 dual-accept 회귀

검증: 전체 389 passed / 36 skipped, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:09:47 +09:00
genichinandClaude Opus 4.8 e10ac519c7 docs(batch): draft-batch BAT-029 (dcy-020 BAT-γ) + FR-7 재정의(계약 키=slot_id)
사용자 결정으로 intent 계약 키를 portfolio_id → slot_id 재정의(코어 native·스냅샷
slots[] round-trip·portfolio-hub 식별 누수 방지). 매도는 이미 slot_id; 매수만 이동
(레거시 portfolio_id dual-accept, 폐기 BAT-δ).

- REQ-061 change-req(CHG-20260610-03): 계약 키 slot_id 로 body/AC 재작성
- dcy-020 FR-7 재정의 주석(2026-06-10)
- draft-batch BAT-029(REQ-061/062/063) + design 확정
  (D1=slot_id 계약, D2=reconcile 3자 확장+A=error/B·C=warning)
- batches/index BAT-029 등록

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:07:10 +09:00
genichinandClaude Opus 4.8 8a377e6fb3 feat(slot): BAT-028 M2/M3 — universe reconcile + 자산 중심 admission (dcy-020/REQ-058·059)
config 게이트 이중 경로(max_active_slots 설정 시 자산 중심, 미설정 시 legacy pool).
운영 데몬은 cutover(BAT-δ) 전까지 pool 무중단.

- repository: find_slot_by_portfolio·count_active(holding+pending_buy+pending_sell)·
  reconcile_universe(생성 멱등/soft-retire/tombstone, allow_retire 가드) — protocol+in_memory+PG
  (PG: ON CONFLICT (instance_key, portfolio_id) WHERE portfolio_id IS NOT NULL)
- snapshot_scheduler: run_once swap 직후 _reconcile_slots(빈 universe skip, ≥50%↓ retire 보류)
- intents: _admit_buy 모드 분기 + _admit_buy_asset_centric(활성화/already_active/
  capacity_full/unknown_portfolio/over-cap, 인스턴스 lock)
- daemon: instance_key·max_active_slots·reconcile_enabled·trading_date_fn 배선
- 신규 테스트: test_universe_reconcile(6), test_asset_centric_admission(6), PG reconcile(1)

검증: 단위 387 passed / 35 skipped, PG-gated 17 passed, ruff clean. legacy 무파손.
REQ-058/059/060 은 Approved 유지(자산 중심 경로 도입 검증; default 전환·cutover 는 BAT-δ).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 11:14:50 +09:00
genichinandClaude Opus 4.8 587e987c5c feat(config): BAT-028 M1 — max_active_slots per-instance TOML (dcy-020/REQ-060)
자산 중심 모드 게이트 + M 값. DaemonInstanceConfig/DaemonConfig 에
max_active_slots: Optional[int] 추가, from_toml 파싱(>0 검증), from_config 전파.
미설정(None) → legacy pool 모드. additive — 전체 375 passed, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 11:06:56 +09:00
genichinandClaude Opus 4.8 8bd9495c4b docs(batch): draft-batch BAT-028 (dcy-020 BAT-β reconcile+admission) + design 확정
REQ-058(universe reconcile)+REQ-059(자산 admission FCFS/M)+REQ-060(max_active_slots).
design 확정(사용자 결정):
- D1: config 게이트 이중경로 (max_active_slots 설정 시 자산중심, 미설정 시 legacy pool;
  운영 데몬은 cutover 전까지 pool 무중단)
- D2: "활성"(M 캡) = holding+pending_buy+pending_sell
- D3: 대량소멸 가드 = N→0 + 급감(50%↓) 경고
batches/index BAT-028(standard, planning) 등록.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 11:04:57 +09:00
genichinandClaude Opus 4.8 017b8185e0 feat(slot): BAT-027 M2/M3 — 상태머신 inactive 재정의 + 인스턴스 스코프 advisory lock (dcy-020/REQ-057)
안 B 점진의 2/3단계. runtime 무변경(idle/closed 별칭 흡수)으로 cascade 통제.

- state.py: SlotState.INACTIVE 추가 + idle/closed 별칭 normalize_state(); 전이 집합
  inactive 기준 재정의(inactive↔pending_buy↔holding↔pending_sell), closed→idle 제거;
  is_allowed_transition 양쪽 정규화; slot_advisory_lock_id(instance_key) 헬퍼
- service.py: SlotService(instance_key) + advisory lock 인스턴스 스코프(self._lock_id)
- __init__: normalize_state/slot_advisory_lock_id export; daemon: instance_key 전달
- 테스트 갱신: test_state(전이/멤버7/락/size12), test_service(closed→idle 제거→reallocation),
  test_slot_entry_count, test_postgresql_repository(closed→idle 거부+reallocation)

검증: 단위 375 passed / 35 skipped, PG-gated(trex_core_test) 8 passed
(마이그레이션 009 드리프트 + lifecycle/reallocation), ruff clean.

REQ-056/057 은 토대만 충족 → Approved 유지(entry_count/trading_date drop·literal
inactive 전면 전환은 BAT-δ; confirm-req-implemented 는 dcy-020 후속 배치 완료 후).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:53:39 +09:00
genichinandClaude Opus 4.8 86c892aa0c feat(slot): BAT-027 M1 — additive 영구 슬롯 필드(instance_key, retired_at) + 마이그레이션 009 (dcy-020/REQ-056)
안 B(점진/additive-first)의 1단계. 라이브 영향·cascade 없이 자산 영구 슬롯 토대의
스키마/모델 필드만 additive 추가.

- Slot.instance_key(기본 "default")·retired_at 추가 + EXPECTED_SLOT_FIELDS 정합
- 마이그레이션 009: instance_key NOT NULL DEFAULT 'default', retired_at,
  부분 UNIQUE(instance_key, portfolio_id) WHERE portfolio_id IS NOT NULL (멱등)
- postgresql _SLOT_COLUMNS/_row_to_slot/update_slot 매핑(row[19]/[20])
- entry_count/trading_date 컬럼은 유지(drop 은 cutover BAT-δ)

검증: 전체 375 passed / 35 skipped, ruff clean (additive — cascade 무파손).
M2(상태머신 inactive 별칭+인스턴스 lock)/M3(소비처 cascade)는 후속.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:42:24 +09:00
genichinandClaude Opus 4.8 4e92134c28 docs(batch): draft-batch BAT-027 (dcy-020 BAT-α 자산 영구 슬롯 토대) + design 확정(안 B)
REQ-056(영구 슬롯 스키마)+REQ-057(상태머신 재정의+인스턴스 lock) 토대 배치.
- planning: delivery plan/Design Gate(R-cascade)/milestones/risks
- design: R-cascade 실측(idle·closed/entry_count/전역 lock/trading_date 소비처) +
  접근안 A/B/C → 안 B(점진/additive-first) 확정:
  * additive 스키마(instance_key·retired_at, entry_count/trading_date 유지→BAT-δ drop)
  * inactive 표준 + idle/closed 별칭(closed→idle 제거)
  * advisory lock 인스턴스 스코프화
  * 부분 UNIQUE(instance_key, portfolio_id) WHERE portfolio_id NOT NULL
  * instance_key NOT NULL DEFAULT 'default'
- batches/index BAT-027(standard, planning) 등록

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:39:33 +09:00
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
genichinandClaude Opus 4.8 e2a71e50e2 docs(req): dcy-020 confirm + 추가 사양(FR-6~8/NFR-4~5/OQ-8) + draft-req REQ-056~065
dcy-020(자산 중심 영구 슬롯 모델) Requirements phase.

- 추가 사양: FR-6(상태머신 재정의), FR-7(intent 자산 키), FR-8(운영자 단일뷰),
  NFR-4(전략 계약 호환), NFR-5(불일치 감지 주기), OQ-8(over-cap=신규 차단·기존 유지),
  dcy-019 산출물 제거 명시. review-discovery 정리 반영.
- confirm-discovery: 상태 draft→confirmed, Handoff 승인, Ready=true,
  Confirmed By=Justin Ko, 2026-06-10. index 행 confirmed.
- draft-req: 신규 REQ-056~065(전부 Proposed) 생성
  - 056 영구 슬롯 스키마 / 057 상태머신+인스턴스 lock / 058 universe reconcile
  - 059 capacity·admission / 060 max_active_slots TOML / 061 intent 자산 키
  - 062 수량 hub 정본+불일치 해소 / 063 slots 단일뷰 / 064 cutover / 065 baseline
  - srs/index Next ID→066, Register 10행, Recent Change Log 갱신
  - dcy-020 생성된 REQ 참조 갱신

기존 REQ-002/003/005/006/007/048 폐기·재정의 change-req 는 후속(문서 단계).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:28:38 +09:00
genichinandClaude Opus 4.8 1db7ab13bb docs(discovery): dcy-020 asset-centric slot model — OQ-1~7 결정 + A-1 확정
자산 중심 슬롯 모델 재설계(issue #1/#20) Discovery. 익명 슬롯 풀 →
portfolio-hub universe 자산과 1:1 영구 슬롯 + 동시 활성(M개) 제어로 substrate 전환.

결정 사항:
- A-1(대전제): 자산 중심 포지션 관리 + 동시 보유 수 제어 (익명 풀 아님)
- OQ-1: FCFS + 가득 차면 거부, 코어 자율 치환 없음
- OQ-2: universe reconcile — 생성 즉시 / 비활성 soft-retire / 보유·pending tombstone / degrade·대량소멸 보류
- OQ-3: 영구 슬롯(키=portfolio_id), trading_date 강등, dcy-014 일일 preallocation 폐기·재해석
- OQ-4: 포지션 사이징(issue #1) 분리(토대만) + 토대 가드 2개
- OQ-5: 불일치 해소 — ground truth=브로커, 표면화·운영자 게이트, 자율청산 금지
- OQ-6: 동시 활성 최대치 M = per-instance TOML(max_active_slots)
- OQ-7: 공유 DB + instance_key 스코프(UNIQUE(instance_key, portfolio_id)) + advisory lock 인스턴스 스코프화, daemon_id 는 universe 파티션/감사용·1:1 가드
- FR-3/FR-4: holding=코어 로컬 정본 / 수량=hub 정본+미러, 청산 수량=브로커 조회

review-discovery 정리 반영(§3 시나리오·§4·§11 현행화). 상태 draft, Handoff 보류
(confirm-discovery 에서 R-1/R-2 책임자·CONFIRMED_BY 지정 + 플래그 전환 예정).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 09:35:16 +09:00
genichinandClaude Opus 4.8 8b2c26c04c feat(config): config 디렉터리 기반 설정 관리 (--config-path/--env-file, trex-orb-v1 정합, BAT-026)
REQ-048/010 change-req. `--config` 를 이름으로 해석 + `--config-path <dir>`
(기본 ./config) + resolve_config_toml(슬래시 포함 값은 하위호환 명시 경로).
`.env` 를 config-dir 결정적 해석(--env-file 우선, 없으면 <config_dir>/.env,
CWD 무관) + config/.env.example + .gitignore config/* 허용목록. 운영자 CLI 도
--config-path/--env-file 동일 적용. from_env() legacy 루트 .env 폴백 유지로
완전 하위호환.

단위 23 + 전체 375 passed, ruff clean, 라이브 스모크(name·path 동일).
REQ-048/010 → Implemented.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 23:45:08 +09:00
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
genichinandClaude Opus 4.8 941d324899 docs(release): REL-002/003 feedback-captured + 포함 batch released 정합
REL-002(BAT-009)·REL-003(BAT-010~013) 을 released→feedback-captured 로 전환해
REL-001/004 와 동일한 완료(종착) 상태로 정합. REL-002 Feedback Handoff 빈
플레이스홀더 정리(tooling 릴리즈, Discovery/REQ Input=없음). 포함 batch
BAT-009~013 release-candidate→released(register + 개별 index) — 누락 정정.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 13:59:41 +09:00
genichinandClaude Opus 4.8 0f56f26eb5 docs(release): REL-004 capture-release-feedback (feedback-captured)
운영자 배포 증거 기반 운영 환류 기록: Feedback Handoff(관찰 사실 +
Discovery/REQ/Change Request Input 분리), REL-004 confirmed→feedback-captured,
포함 BAT-014~023 release-candidate→released(register + 개별 index).

후속 입력: issue #16(preallocation 누락, Discovery), dcy-019(REQ 대기),
BAT-024(차기 release 편입), daily_symbol_entries 제거(REQ-002 change-req).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 13:53:24 +09:00
genichin b07b123165 docs(rel-004): record deployment verification evidence 2026-06-09 13:45:38 +09:00
genichinandClaude Opus 4.8 f0d7ee01c3 docs(discovery): dcy-019 slot entry_count + closed 재할당 정책 (issue #18, confirmed)
issue #18(슬롯별 entry_count + closed 슬롯 재할당)을 Discovery 로 정리·확정.
OQ-1(entry_count=daily_slot 단독, daily_symbol_entries 와 분리)·OQ-2(tie-break:
entry_count→updated_at→slot_id)·OQ-3(closed 직접 후보, closed→pending_buy 신규
전이, →pending_buy 시 +1) 사용자 결정 반영. daily_symbol_entries 제거는 별도
REQ-002 change-req 트랙. confirm-discovery 게이트 통과 → confirmed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 13:43:27 +09:00
genichinandClaude Opus 4.8 1cbbb89091 feat(cli): enter --forced-close-at 시간 기반 자동청산 옵션 (issue #17, BAT-024)
trex-core enter 에 --forced-close-at <ISO8601>(절대시간) 옵션 추가.
지정 시 buy intent payload 의 기존 forced_close_at 에 매핑(계약·도메인·
forced-close 루프 REQ-037 불변, CLI 노출 갭만 보완). 잘못된 형식은 제출
전 거부, 미지정 시 미포함(하위호환). 상대시간 옵션은 미채택.

REQ-032 change-req(CHG-20260609-01/02) → BAT-024(batch-lite) →
Implemented. 단위 353 passed, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 13:10:21 +09:00
genichinandClaude Opus 4.8 fec9411d33 docs(release): REL-004 에 BAT-022/023 편입 + 재-confirm (confirmed)
릴리즈되지 않은 release-candidate 배치(BAT-022 슬롯 상태 가시화,
BAT-023 ledger 현금/포지션 write-back·option D)를 REL-004 범위에 추가.
확장 범위 증거(BAT-022 실 인프라 운영 재현, BAT-023 인프라 게이트
385 passed) 반영 후 confirm-release 게이트 통과 → Status confirmed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 08:52:12 +09:00
genichinandClaude Opus 4.8 2bfecd59a8 feat(ledger): dcy-018 option D cash/position write-back + 추정 현금 (BAT-023)
ledger write 응답의 portfolio-hub 권위 cash/quantity 를 스냅샷에 write-back 해
매수/매도 직후 "수량 live·현금 stale" 비대칭 제거(option D 활성화). portfolio-hub#8
(*_after 응답) 동작 중 확인으로 그간 deferred 됐던 REQ-030 을 닫음.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-018 OQ-3 a).
- REQ-017: record_trade → LedgerWriteOutcome{result, cash_balance_after,
  asset_quantity_after}. 어댑터가 응답 root flat *_after 파싱(new+duplicate, 누락 None)
- REQ-019: LedgerWriter 에 SnapshotStore 주입 → new+duplicate write-back
  (best-effort, *_after 절대값이라 멱등). LedgerOutbox.pending_cash_delta()
- REQ-029: 추정 현금 오버레이(_apply_cash_estimate, cash_estimated 라벨, OQ-4 i)
  + 슬롯 오버레이 유지(OQ-1 B). 미정산 outbox delta 기반, write-back 수렴
- REQ-030: option D 활성화 → Approved→Implemented

best-effort 격리(NFR-1): write-back/추정 실패가 ledger 멱등·청산 무차단.
배치 번호: 동시 커밋된 BAT-022(slot-state, dcy-016)와 충돌해 BAT-023 으로 배정.

검증: 단위 350 passed/35 skipped, 인프라 게이트(PG+RabbitMQ) 385 passed, ruff clean.
신규 test_ledger_option_d + adapter/PG 테스트. BAT-023 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 21:50:56 +09:00
genichinandClaude Opus 4.8 63da87c9b3 fix(cli): BAT-022 slots 명령이 universe 대신 실제 슬롯 상태 표시 (dcy-016 후속)
`trex-core slots` 가 snapshot RPC 의 universe `assets`(portfolio)를 슬롯 상태로
오인 표시하던 갭 정정. snapshot envelope 이 슬롯 상태를 운반하지 않아 발생
(10개 슬롯인데 universe 1개·status 없음 — BAT-007 HTTP 슬롯 read 제거 후
슬롯 상태 read 표면 부재가 근인).

- REQ-028 (CHG-20260608-01): snapshot envelope 에 read-only per-slot `slots[]`
  additive 추가(AC-4). strategy `assets[]`(universe, no-price) 불변.
- REQ-032 (CHG-20260608-03): `_cmd_slots` 가 envelope `slots[]`(실제 슬롯 상태)
  표시 + `--status` 를 슬롯 status 기준 client-side 필터 + watchdog 결합.
  `universe` 는 `assets[]` 유지. `universe --json` 도 universe 데이터로 scope.
- canonical `portfolio.slot_to_dict` 단일화 — BAT-007 stub / BAT-008 envelope
  두 경로가 동일 슬롯 스키마(외부명 `entry_price` 유지, dcy-012 호환).
- interface-contract 에 `slots[]` 계약 + `assets[]` vs `slots[]` 구분 반영.

검증: 단위 338 passed + ruff clean + 신규 코드 데몬으로 실 PostgreSQL/RabbitMQ
운영 재현 PASS(slots=10·status·DB 일치·universe 분리·비침습). REQ-028/032
Implemented, BAT-022 release-candidate. pytest 인프라 게이트는 Human Approval
Memo 수용(운영 재현이 실 경로 커버).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 19:54:42 +09:00
genichinandClaude Opus 4.8 a0a149114d docs(release): confirm REL-004 (app-service) — BAT-014~021 통합
confirm-release 게이트 통과 → Status draft→confirmed (문서 + index).
- 포함 batch(BAT-014~021) 전부 release-candidate
- Rollout/Rollback/Verification Checklist 완비
- app-service 검증 근거: Pre-Release Run Evidence(실 데몬 기동 RUNNING+
  마이그레이션 006/007 적용 + 운영자 CLI universe/slots/enter/exit e2e +
  ledger completed; buy 심볼 resolver 버그 검출·수정 포함)

다음: 운영자 실 서버 배포 후 Release Execution Evidence 채워 released 전환.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 17:53:46 +09:00
genichinandClaude Opus 4.8 a570ac659e fix(daemon): buy 심볼 resolver 결함 수정 + REL-004 draft (운영자 run 증거)
REL-004(미릴리즈 BAT-014~021 통합) draft-release 작성. confirm-release 전
운영자 프로그램 run-the-app 검증(실 데몬 + trex-core CLI e2e)을 수행했고,
369 passed 가 놓친 실 프로덕션 버그를 검출·수정했다.

- fix(REQ-007 CHG-20260608-03): Daemon._resolve_symbol 이 SnapshotAsset.symbol
  (없는 속성)을 접근 → 데몬 buy admission 매 요청 AttributeError → intent RPC
  타임아웃(실 데몬 매수 전면 불능). asset.item.symbol 로 수정. 단위 테스트가
  stub resolver 를 주입해 실 배선을 한 번도 실행하지 않아 미검출이었음
- test: tests/runtime/test_daemon_resolve_symbol.py — 실 Daemon._resolve_symbol
  × 실 SnapshotStore 회귀 가드(수정 전 실패하는 테스트)
- docs(release): rel-004 draft(app-service, BAT-014~021) + Pre-Release Run
  Evidence(데몬 기동 + universe/slots/enter/exit e2e + ledger completed +
  버그 검출·수정 + LIVE 미검증 한계) + releases/index REL-004 행

검증: 실 데몬 재기동 후 buy/sell e2e admitted→체결→closed + ledger completed,
단위 337 passed, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 17:38:34 +09:00
genichinandClaude Opus 4.8 6d7bca1460 feat(safety-sell): dcy-017 워치독 소유권 가시화 — snapshot 상태 + 발동 로깅 (BAT-021)
전략 이탈로 슬롯이 내부 청산 루틴(워치독) 소유로 넘어간 상태가 무성이라
운영자가 인지할 수 없던 문제(issue #12)를 가시화한다.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-017 OQ-3; Redis 미채택).
- REQ-034/021: WatchdogStore.last_seen + snapshot RPC 응답에 holding 슬롯
  워치독 상태(expired/last_seen) read-only 동봉(best-effort)
- REQ-032: trex-core slots 가 expired 슬롯을 WATCHDOG-OWNED(전략 이탈) 표시
- REQ-037/038/039: safety-sell 워치독 소유 진입(WARN)/이탈(INFO) + 발동
  (forced_close·stop_loss=WARN, take_profit·market_close=INFO) 로그 +
  in-process 카운터(SafetySellService.counters), 구조화 필드(slot_id/
  portfolio_id/reason/phase/instance_key). per-tick 스킵은 카운터만
- REQ-042: runtime-flows/interface-contract 정합

best-effort 격리(NFR-1): 모든 가시화는 예외 격리 — 워치독 판정·청산 불변.
dcy-016 억제 읽기로 관측이 워치독을 리셋하지 않음(비침습).

검증: 단위 335 passed/34 skipped, 인프라 게이트(PG+RabbitMQ) 369 passed, ruff clean.
신규 test_safety_sell_visibility(6) + snapshot watchdog(1) + CLI(1). BAT-021 rc.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 17:10:26 +09:00
genichinandClaude Opus 4.8 d09b93195f feat(cli): dcy-016 운영자 CLI 확장 (universe/slots/enter/exit) + 워치독 억제 (BAT-020)
운영자가 조회·매수·매도를 CLI 로 수행하되 데몬 RabbitMQ RPC 로 통일해 단일
writer admission·불변식을 보존(DB 직접 쓰기 없음)하고, 운영자 조회가 전략
생존 신호로 오인되지 않게 워치독을 억제한다.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-016 OQ-3).
- REQ-032: CLI universe/slots(snapshot RPC) + enter(buy)/exit(sell) intent RPC
  + 인스턴스 라우팅(--config/--instance/default) + enter/exit 안전장치
  (확인 프롬프트 기본 ON / --yes(paper) / --yes --live(이중 ack) / --dry-run)
  + 전 명령 --json. pause/resume 는 direct-DB 유지
- REQ-022: CLI request-reply RPC 클라이언트(call_rpc) 재사용
- REQ-021/034: snapshot 요청 워치독 억제 플래그(touch_watchdog/actor=operator)
  → 핸들러가 last_seen_at 갱신 스킵. 기본값 현행 유지(하위호환). 운영자
  조회가 죽은 전략의 safety-sell 을 무력화하던 결함(R-4) 제거
- REQ-026: interface-contract/runtime-flows 정합

CLI 는 rpc/confirm 주입 가능(테스트 broker/DB-free). snapshot envelope 은
asset-centric 이라 exit 은 운영자 제공 slot_id 사용(slot_id 노출은 본 주기 밖).

검증: 단위 327 passed/34 skipped, 인프라 게이트(PG+RabbitMQ) 361 passed, ruff clean.
신규 test_cli_operator(14) + snapshot 워치독 억제(2). BAT-020 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 16:48:26 +09:00
genichinandClaude Opus 4.8 b851b927ee fix(ledger): dcy-015 outbox 영속 오류 분류 + 백오프/dead-letter (BAT-019)
portfolio-hub 404(미등록 포트폴리오)가 retryable 로 분류되어 백오프·상한 없이
초당 영구 재시도되던 버그(issue #13, 실측 930회) 정정.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-015 OQ-3; 백오프 env 는 REQ-019 흡수).
- REQ-017: 404/400/422 → LedgerPermanentError 분류 (409 conflict / 408·429·5xx·
  network retryable 불변). LedgerPort 에 permanent 타입 추가
- REQ-019: 영속 → 터미널 delivery_failed 즉시(재시도 0). retryable 지수 백오프
  +jitter+next_retry_at, max_attempts 초과 시 dead-letter delivery_failed.
  list_pending 이 백오프 행 스킵(head-of-line 보호). 마이그레이션 007(status enum
  +next_retry_at). 백오프 env(base/cap/max-attempts)
- REQ-018: 터미널/dead-letter WARN + WriterStats.delivery_failed 카운터 가시화
- REQ-020: runtime-flows/data-model/interface-contract 정합

단일 터미널 delivery_failed(permanent/dead-letter, last_outcome 로 사유 구분) —
conflict_blocked 패턴과 동형. dead-letter 는 운영자 재처리 가능 상태.

검증: 단위 311 passed/34 skipped, 인프라 게이트(PG+RabbitMQ) 345 passed, ruff clean.
신규 test_ledger_outbox_backoff + adapter/PG 테스트, 기존 retryable 백오프 정합.
BAT-019 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 16:12:17 +09:00
genichinandClaude Opus 4.8 0b7db66463 feat(runtime): dcy-014 trading_date KST 타임존 분리 + 일일 슬롯 preallocation (BAT-018)
데몬이 시스템 UTC 날짜로 슬롯을 1회만 preallocate 해 trading_date 가 KST 캘린더와
어긋나고 재시작 없이는 다음날 슬롯이 안 생기던 문제(issue #14) 정정.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-014 OQ-3; 스케줄러는 REQ-030 패턴 준용).
- REQ-005: trading_date 를 설정 타임존(기본 Asia/Seoul) 기준 계산(timestamp 는 UTC
  유지). DailyPreallocationScheduler 신규 — TZ 일자당 1회 멱등 fire, 재시작 없이
  다음날 슬롯 자동 생성. setup() 배선 + trex-preallocation 스레드
- REQ-048: TOML trading_timezone/daily_preallocation_time 키 + from_config 전파
- REQ-009: runtime-flows/data-model 정합 + instance.example.toml

OQ-1 기본 00:00(TZ 자정, TOML 설정 가능) / OQ-2 매 캘린더일 생성(거래일 캘린더 후속).
멱등 preallocate 로 중복 tick·다중 인스턴스 중복 생성 0.

검증: 단위 302 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 334 passed, ruff clean.
신규 test_preallocation_scheduler(고정 clock) + test_instance_config 확장.
BAT-018 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 15:39:04 +09:00
genichinandClaude Opus 4.8 4746f74aae fix(broker): dcy-013 KIS 외부 취소 감지 + 부분 체결 회계 + stale 워치독 (BAT-017)
KIS 계좌에서 직접 매도 주문을 취소하면 poll_fill 이 cncl_yn 을 파싱하지 않아
슬롯이 pending_sell 에 영구히 갇히고 죽은 주문을 무한 폴링하던 버그(issue #9)
정정.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-013 OQ-3).
- REQ-012: KIS poll_fill cncl_yn 파싱 → 외부 취소 감지. FillStatus.cancelled
  /is_partial_cancel 추가. 체결 0 취소→cancelled, 부분 체결 후 취소→partial+cancelled
- REQ-013: 집행 _on_partial_cancel — 체결분 원장 1회 + qty 차감(매도 잔여/매수 체결분)
  + holding 복귀 (OQ-1 A안). 전량 취소는 기존 롤백 경로 재사용
- REQ-018: 부분 체결분 원장 1회 기록 (_record_ledger 재사용)
- REQ-031: 잔여 포지션 정합 연계 (slot.qty ↔ 실 잔고, 과매도 방지)
- REQ-014: pending stale 워치독 Alert-only (TREX_PENDING_STALE_THRESHOLD,
  WARN+카운터, 상태 미변경) — 취소 감지 누락 backstop
- REQ-015: interface-contract/runtime-flows 정합

전량 취소는 holding 자동 복구(limit_price clear→재매도 시장가, dcy-012 연계).
KIS cncl_yn 실 규약은 운영 검증(미지 값 보수 처리 + 워치독 backstop).

검증: 단위 294 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 326 passed, ruff clean.
신규 test_kis_cancel(httpx stub) + test_execution_cancel(programmable broker).
BAT-017 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 14:11:49 +09:00
genichinandClaude Opus 4.8 cc28e1fba5 fix(execution): dcy-012 매도 가격 버그 정정 — slot entry_price→limit_price rename (BAT-016)
매도(sell) 주문이 현재가가 아닌 매수가(entry_price) 지정가로 나가던 버그(issue #10)
정정. 슬롯의 매수 전용 entry_price 를 side 무관 "현재 pending 주문 지정가"
limit_price 로 내부 rename 하고, pending 이탈(→holding/→closed) 시 clear 해
매수 지정가가 매도로 누수되는 경로를 구조적으로 제거.

거버넌스: 전부 change-req (신규 REQ 없음, dcy-012 OQ-3).
- REQ-002: Slot entry_price→limit_price rename + clear-on-exit 생애주기
- REQ-006: daily_slot 컬럼 rename 마이그레이션 006 (idempotent) + persistence 매핑
- REQ-013: _dispatch 가 slot.limit_price 단일 필드로 가격/주문유형 결정
- REQ-007: SellIntent/sell payload optional limit_price + _admit_sell 운반
- REQ-036: SlotService.sell optional 가격 → 자율 매도(safety-sell/kill-switch) 시장가
- REQ-003: 컬럼 계약/드리프트 가드 limit_price 반영
- REQ-015: runtime-flows/interface-contract/data-model 정합

매도 정책(OQ-1 하이브리드): 가격 지정→지정가("00"), 미지정→시장가("01").
자율 매도는 가격 미전달 → 항상 시장가 (손절 미체결 pending_sell 갇힘 방지, issue #9 연계).

검증: 단위 286 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 318 passed, ruff clean.
신규 test_sell_pricing(recording broker)로 지정가 매수 슬롯의 매도가 매수가
재사용 안 함을 직접 검증. BAT-016 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 13:41:46 +09:00
genichinandClaude Opus 4.8 aee3512383 feat(intents): dcy-011 buy intent portfolio_id 필수 계약 + ledger skip 가시화 (BAT-015)
dcy-011 전 주기 delivery. issue #6(buy 식별자 정정) + issue #11(ledger silent skip) 흡수.
거버넌스: 기존 Implemented REQ는 change-req, 신규 기능만 신규 REQ(OQ-3).

- REQ-007 (change-req): buy admission portfolio_id 필수화 + SnapshotStore symbol
  resolve + unknown_portfolio 거부 (hard cutover, OQ-1/OQ-2)
- REQ-021 (change-req): buy 메시지 payload symbol 제거
- REQ-018 (change-req): _record_ledger skip 가시화 (WARN + ledger_skipped 카운터)
- REQ-055 (신규): closed↔ledger_outbox anti-join 운영 점검 find_ledger_gap_slots

코드: intents.py(BuyIntent portfolio_id 필수 + resolve_symbol 주입 + _admit_buy
reject 분기), messaging_handlers.py, runtime/daemon.py(_resolve_symbol 배선),
execution.py(skip WARN 로그), adapters/persistence/ops_checks.py(신규 anti-join).

검증: 단위 282 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 314 passed, ruff clean.
BAT-015(standard) release-candidate. srs/index Next ID → REQ-056.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:57:51 +09:00
genichin a24ebb242e docs: add discovery dcy-011 2026-06-08 12:28:17 +09:00
genichinandClaude Opus 4.8 565af6792c feat(safety-sell): dcy-010 BAT-014 — 영속 거부 재시도 쿨다운 (REQ-052~054)
dcy-010(safety-sell 영속 거부 재시도 백오프) 전체 SDLC: draft-req → confirm-req →
draft-batch(BAT-014 batch-lite) → run-batch-delivery → confirm-req-implemented.
2026-06-07 실 KIS LIVE SL/TP e2e에서 발견한 KIS 주문 spam 위험(영속 거부 시
매도 무한 재제출) 차단.

- REQ-052 (Integration): SafetySellService per-slot 인메모리 쿨다운
  (_in_cooldown/_attempt_sell/_prune_cooldown) — forced_close·stop-loss·take-profit
  트리거에 min_retry_interval_sec(600s) 이내 재시도 skip(가격 poll 포함) +
  max_retry_warn_count(3) 도달 시 WARNING + holding 이탈 정리. market_close 제외.
- REQ-053 (Configuration): SafetySellConfig min_retry_interval_sec/max_retry_warn_count
  + TREX_SAFETY_SELL_MIN_RETRY_INTERVAL/MAX_RETRY_WARN_COUNT env (additive)
- REQ-054 (Documentation): runtime-flows 쿨다운 flow + 가격체크 tr_id(FHKST01010100) 정정

인메모리 only(DB/스레드/인터페이스 변경 없음), default 미설정 시 기존 동작 불변.
검증: 신규 8 단위(쿨다운 6 + config 2), 전체 278 passed, ruff clean.
REQ-052~054 Implemented, BAT-014 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 00:35:11 +09:00
genichin 5eebe9c4e8 docs: update rel-003 safety killswitch release 2026-06-07 23:00:24 +09:00
genichinandClaude Sonnet 4.6 7b40ffad64 docs(discovery): dcy-010 confirmed — safety-sell 영속 거부 재시도 백오프
모든 OQ Answered, 플레이스홀더 해소, Justin Ko 승인 완료.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 22:59:21 +09:00
genichinandClaude Sonnet 4.6 b0539e752c docs(discovery): dcy-010 OQ-3 Answered — 단일 per-slot 쿨다운 확정
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 17:21:16 +09:00
genichinandClaude Opus 4.8 cc063afdb9 docs(release): REL-003 검증 한계/미검증 영역 명시 (운영자 핸드오프)
배포 차단 아님 전제로 실 KIS 쓰기 경로 4가지 미검증을 Verification Checklist에 명시:
LIVE 체결→ledger 미실증, kill_switch LIVE 미실행, 실 2-인스턴스 동시기동 미검증,
거래일 성공 LIVE 주문 0건 + 운영 DB 최초 적용. + 배포 후 차기 거래일 실증 권고.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 16:01:08 +09:00
genichinandClaude Sonnet 4.6 3a2020012d docs(discovery): dcy-010 safety-sell 영속 거부 재시도 백오프 — KIS 주문 spam 방지 슬롯별 쿨다운 정책
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 15:54:30 +09:00
genichin 278076a376 docs(discovery): dcy-010 safety-sell 영속 거부 재시도 백오프 Discovery 초안 2026-06-07 15:53:47 +09:00
genichinandClaude Opus 4.8 cb288c24c2 docs(release): REL-003 통합 confirmed — BAT-010~013 (safety-sell + kill-switch + multi-instance)
REL-003/004/005를 단일 app-service 릴리즈로 통합(사용자 결정). REL-003에
BAT-010·011(dcy-007 safety-sell) + BAT-012(dcy-008 kill-switch) +
BAT-013(dcy-009 multi-instance)를 묶고 rename, REL-004/005 draft 폐기.

- 파일 rename: rel-003 core-autonomous-safety-sell → safety-killswitch-multi-instance
- Scope/Rollout/Rollback/Verification 통합 (⚠️ --config 필수화 파괴적 기동 변경 +
  제어 큐 pause.req→control.req + 마이그레이션 004/005 + LIVE safety-sell/kill_switch 안전 주의)
- confirm-release: draft → confirmed (단위 271 + 인프라 게이트 301 passed + 전 e2e PASS)
- releases/index: REL-003 통합 행, REL-004/005 제거

배포 핸드오프 가능 상태(confirmed). 운영자는 commit SHA + REL-003 Rollout Plan으로 배포.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 15:45:01 +09:00
genichinandClaude Opus 4.8 9f83c64a40 feat(multi-instance): dcy-009 BAT-013 — RabbitMQ 다중 인스턴스 토폴로지 (REQ-048~051)
dcy-009(다중 인스턴스 RabbitMQ 토폴로지) 전체 SDLC: draft-req → confirm-req →
draft-batch(BAT-013) → run-batch-delivery → confirm-req-implemented.

- REQ-048 (Configuration): DaemonInstanceConfig.from_toml + DaemonConfig.from_config
  (env 병합, portfolio_hub_token 주입) + 데몬 --config 필수 argparse + .gitignore 인스턴스
  TOML + config/instance.example.toml
- REQ-049 (Interface): topology 동적 큐명 빌더 intent/snapshot/control_queue(instance_key)
  — default=리터럴 큐명(하위호환), named=`{base}.{instance_key}` + daemon per-instance 구독
- REQ-050 (Integration): trex.direct(topic)/trex.broadcast(fanout) exchange +
  declare_topology(instance_key) per-instance binding + control dual binding + direct_routing_key
- REQ-051 (Documentation): interface-contract/runtime-flows/project-structure 정합

하위호환: instance_key="default" → 기존 리터럴 큐명·RPC 경로 무회귀(FR-5).
split-brain 방지(NFR-3): 인스턴스 전용 큐. 민감값(NFR-4): TOML + gitignore.

검증: 신규 9 단위 + RabbitMQ 라우팅 2, 단위 271 passed,
인프라 게이트 301 passed(directed 격리 S-2 + broadcast dual S-3 + default 무회귀 S-4),
ruff clean. REQ-048~051 Implemented, BAT-013 release-candidate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 15:10:36 +09:00
genichin 7e23648489 feat: add kill-switch control flow 2026-06-07 14:00:20 +09:00
genichinandClaude Opus 4.8 c912c08071 docs(req): dcy-008 kill-switch confirm-discovery + REQ-043~047 (Approved)
dcy-008(비상 정지/kill-switch) OQ-2(별도 테이블/store)·OQ-4(수동 해제
resume_kill_switch) 결정 → confirm-discovery(confirmed) → draft-req →
confirm-req(5개 Approved).

- REQ-043 (Interface): trex.pause.req → trex.control.req 제어 채널 + action dispatch (OQ-1)
- REQ-044 (Data): day-scoped killswitch_exclusion 테이블 + store + 005 마이그레이션 (OQ-2)
- REQ-045 (Interface): kill_switch 실행 — 범위별 holding 순차 sell() + idempotency + 이력 (NFR-1/2 흡수)
- REQ-046 (Interface): 당일 제외 masking + 다음 거래일 자동복귀 + resume_kill_switch (OQ-4, NFR-3 흡수)
- REQ-047 (Documentation): baseline 3문서 정합

OQ-3(pending_buy 롤백)은 REQ Deferred. srs index Next ID REQ-048, Register +5,
요약 갱신. dcy-008 생성된 REQ 참조 기록.

dcy-009(멀티 인스턴스 RabbitMQ, draft)는 별도 주제로 제외.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 11:29:31 +09:00
genichinandClaude Opus 4.8 6fda381f62 docs(release): REL-003 — LIVE SL/TP e2e 검증 + 영속 거부 재시도 백오프 환류
실 KIS LIVE SL/TP e2e: 실 시세(FHKST01010100, 329000) → stop_loss 트리거
→ 실 KIS 매도 제출 → "장운영일자가 주문일과 상이합니다"(휴장) 거부 → 안전 롤백
end-to-end 확인. forced_close/장마감/update_thresholds 는 paper daemon e2e 통과.

발견(Change Request Input 기록): 영속 거부 상황에서 safety-sell 이 poll
interval 마다 거부 주문을 무한 재제출 → 재시도 백오프/쿨다운 후속 후보.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 10:43:36 +09:00
genichinandClaude Sonnet 4.6 0082d3b5da fix(kis): REQ-038 현재가 tr_id 정정 + REL-003 확정 + dcy-008 kill-switch Discovery
## REQ-038 CHG-04/05: KIS 시세 tr_id 정정 (FHKST01010100)
- kis.py _tr_price(): TTTC8397R/VTTC8397R → FHKST01010100 (실전/모의 공용)
  배포 전 실 KIS LIVE 진단에서 구 tr_id가 rt_cd=1 "없는 서비스 코드"로 거부됨을
  확인 — stop-loss/take-profit이 LIVE에서 조용히 미발동하는 결함이었음.
  FHKST01010100으로 정정 후 get_current_price('005930')=329000(rt_cd=0) 확인.
- test_kis_price.py: AC-7 테스트 정정 (FHKST01010100 공용 검증)
- REQ-038: CHG-04/05 Change Log 추가, Requirement/AC-7/Notes 정정
- BAT-011 implementation.md: LIVE 검증 및 tr_id 정정 이력 추가
- BAT-011 verification.md: AC-7 evidence를 CHG-04 정정 버전으로 갱신
- docs/srs/index.md: CHG-04/05 Change Log 항목 추가

## REL-003: core 자율 안전 매도 release 문서 생성
- docs/releases/rel-003_20260607_core-autonomous-safety-sell.md 신규 생성
  (BAT-010 + BAT-011, app-service profile, Status: confirmed)
- docs/releases/index.md: REL-003 행 추가

## dcy-008: 비상 정지/강제 청산(kill-switch) Discovery 초안
- docs/discovery/dcy-008_20260607_emergency-stop-kill-switch.md 신규 생성
  GitHub #3 기반; SlotService.sell() 재사용, 당일 전략 제외 day-scoped
  FR 6개, NFR 3개, OQ 4개 (트리거 표면/영속 방식/수동 해제 결정 필요)
- docs/discovery/index.md: dcy-008 행 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 10:17:36 +09:00
genichinandClaude Opus 4.8 a30efa8f3b feat(safety-sell): dcy-007 core 자율 안전 매도 — BAT-010 기반 + BAT-011 트리거
dcy-007(core 자율 안전 매도) 전체 delivery. BAT-010 기반 인프라가 미커밋
상태였고 BAT-011 트리거 레이어와 공유 파일에서 섞여 있어 한 커밋으로 묶음.

BAT-010 (REQ-034/035/036/041, release-candidate):
- WatchdogStore(application/watchdog.py) + snapshot RPC 워치독 갱신
- Slot stop_loss_price/take_profit_price 필드 + 004_add_price_thresholds.sql
- SlotService.sell() 자율 매도 내부 경로 + idempotency
- SafetySellConfig env 5종 파싱

BAT-011 (REQ-037/038/039/040/042, release-candidate):
- SafetySellService(application/safety_sell.py): forced_close 만기 / stop-loss·
  take-profit KIS polling / 장 마감 강제 청산 + trex-safety-sell 7번째 스레드
- BrokerPort.get_current_price + KIS inquire-price(TTTC8397R/VTTC8397R, stck_prpr)
  + paper stub
- SlotService.update_thresholds() + intent RPC update_thresholds 액션
  (부분 갱신/null 해제, 워치독 last_seen_at 리셋)
- baseline 3문서 정합(interface-contract/runtime-flows/project-structure)

거버넌스: REQ-034~042 Implemented 동기화, BAT-010/011 release-candidate,
dcy-007 discovery 포함.

검증: 신규 38 테스트 green, 단위 236 passed/23 skipped,
인프라 게이트(PG+RabbitMQ) 259 passed(마이그레이션 001~004 round-trip 포함),
ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 08:32:30 +09:00
genichin e4e5228972 docs: add dcy-007 safety sell discovery 2026-06-07 00:28:26 +09:00
genichinandClaude Opus 4.8 c8174e8bb6 docs(release): REL-001 released → feedback-captured (BAT-001~008 released)
운영자(Hermes Agent) 실 환경 배포 evidence(revision 71faa23, host 86ba33f2997a,
broker=kis LIVE, 2026-06-06T11:18:16Z) 반영:
- Release Execution Evidence 기재(배포 facts + app-service profile checks +
  동일 revision 71faa23 pre-deploy 게이트 재현 보강).
- Rollback Outcome 의미 정정: 운영자 보고 "rollback yes"는 배포 롤백이 아니라
  휴장일(현충일) KIS 거절에 따른 slot pending_buy→idle 정상 복구(매수 거부 경로 smoke 성공).
- capture-release-feedback: release feedback-captured 전환,
  포함 batch BAT-001~008 released 전환.
- 잔여(차기 거래일 실증): ledger flush(fill→ledger), 마이그레이션 명시 로그,
  포지션 정합/warning 마스킹 결과 로그 — Feedback Handoff 기록.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-07 00:26:08 +09:00
genichinandClaude Opus 4.8 71faa23e5d docs(release): REL-002 released — BAT-009 merged + pushed to main
Record deployment evidence for REL-002 (tooling): bat-009 fast-forward
merged to main and pushed (ca75700..7b6ed55). No migration/restart;
broker=kis unaffected. Status confirmed -> released.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 18:38:09 +09:00
genichinandClaude Opus 4.8 7b6ed5591c docs(release): draft + confirm REL-002 (tooling) for BAT-009
REL-002 bundles BAT-009 (paper broker env tuning, REQ-010 AC-5) as a
tooling-profile release. Rollout/rollback/verification ready; status
confirmed. No DB migration or daemon restart; broker=kis runtime
unaffected (paper config only).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 18:36:25 +09:00
genichinandClaude Opus 4.8 2f57aad7b2 feat(config): expose paper broker tuning via env (REQ-010 AC-5, BAT-009)
Wire the existing PaperBroker scenario knobs (fill_after_polls /
qty_per_poll / reject_symbols) to daemon env so REQ-011 AC-2 e2e
scenarios (delayed / partial / reject) can be reproduced by a daemon
restart. Unset == prior PaperBroker() behaviour, byte-for-byte (no
regression).

- config.py: PaperBrokerConfig + from_env parsing (TREX_PAPER_*)
- daemon.py: _build_broker injects config.paper into PaperBroker
- .env.example: document the 3 paper tuning keys (paper-only, e2e)
- tests: paper broker defaults + env tuning parsing

SDLC: REQ-010 CHG-20260606-01 (AC-5 added) / -02 (Implemented);
BAT-009 batch-lite release-candidate; REL-001 feedback handoff records
pre-deployment e2e observations incl. event-publisher idle-drop and
paper correlation_id collision (GitHub #4, #5).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 16:49:51 +09:00
genichinandClaude Opus 4.7 f8c5661147 docs(release): confirm REL-001 trex-core slot-core baseline (BAT-001~008)
Bundle BAT-001~008 into REL-001 (app-service profile) and promote to
confirmed. Register index row added.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 11:27:35 +09:00
genichinandClaude Opus 4.7 9e64a24441 fix: align portfolio-hub ledger write adapter to live API contract
REQ-017 CHG-20260606-01. Live portfolio-hub returned 404 for the
trex-orbit-assumed POST /v1/assets/{asset_id}/ledger/trades. Correct to
POST /v1/portfolios/{portfolio_id}/ledger/trades with body keys
quantity/fee_amount/tax_amount (was qty/fee/tax), success 201. Reverified
with live e2e (201 Created, outbox COMPLETED) + durability drain of the
prior 404'd item. Resolves the REL-001 ledger-write release blocker.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 11:27:30 +09:00
genichinandClaude Opus 4.7 e24de29335 docs(srs): REQ-027 CHG-04 — correct portfolio-hub read contract for release
Align REQ-027 and BAT-008 verification/design with the live portfolio-hub
API discovered during release prep: whoami via /v1/user_info, {portfolios}
envelope, client-side managed_by_daemon_id filter, http:// scheme default,
and strategy fields deferred (None/{}). Records the re-verification evidence
(new contract tests + live e2e) so BAT-008 can bundle into the first release
with non-stale verification. REQ-027 stays Implemented.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 10:41:30 +09:00
genichinandClaude Opus 4.7 515af7a068 docs(srs): REQ-029 CHG-04 — orb-v1 snapshot consumption note
Record that the first strategy (orb-v1) queries view=buyable without a
strategy_key, so missing PortfolioItem strategy fields are harmless for the
single-strategy stage. Documentation-only; REQ-029 stays Implemented.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 10:34:40 +09:00
genichinandClaude Opus 4.7 43bad2424e fix: align portfolio-hub read adapter to live API contract
whoami now hits GET /v1/user_info (the live endpoint; /v1/auth/whoami
does not exist), get_portfolios parses the {portfolios:[...],total} envelope
and filters by managed_by_daemon_id client-side (the list endpoint is
token-scoped, no such query param), and a missing URL scheme now defaults
to http:// so a bare host can't silently degrade the daemon.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 10:34:35 +09:00
genichin ca757009f5 feat: add portfolio snapshot read layer 2026-06-06 09:33:00 +09:00
genichin 56e977a7ad update .gitignore 2026-06-06 00:04:07 +09:00
genichin 6c7a1cf6f6 feat: add messaging transport rollout 2026-06-06 00:02:52 +09:00
genichin 4b91343ee8 docs: advance dcy-005 asset snapshot discovery 2026-06-05 22:41:29 +09:00
genichinandClaude Opus 4.8 0d6854aaa5 docs(discovery): add dcy-006 RabbitMQ transport (confirmed) + advance dcy-005
dcy-006 (new, confirmed — Confirmed By: Justin): trex-core ↔ 전략 모듈
통신 transport를 RabbitMQ로 전환. OQ-1~7 전부 Answered —
- HTTP /v1 API 완전 대체(표면 0, healthz 제거; liveness=프로세스 감독)
- 토폴로지: 스냅샷·intent admission = RPC(direct reply-to), 이벤트 = topic
- delivery: at-least-once + idempotency = effectively-once, 스냅샷 reconcile
- degrade: 버퍼링 금지·보수적 중단, core 자율 안전 매도 독립(미구현, 추후)
- 클라이언트: pika 동기 + 스레드 런타임(uvicorn 제거)
- 자격증명: TREX_RABBITMQ_URL

dcy-005 (advance): strategy_id 필터 + 런타임 pause/resume(FR-8/9);
옵션 D(체결 시 portfolio-hub write 응답 cash_balance_after/asset_quantity_after
갱신, portfolio-hub#8); OQ-4 holding 포함·pending/warning/pause 마스킹;
OQ-11 view-mode 파라미터 + OQ-12; 응답 용어 sweep.

index: dcy-006 행 추가(confirmed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 22:33:42 +09:00
genichin aed54911d4 chore: commit current workspace changes 2026-06-04 23:38:42 +09:00
genichinandClaude Opus 4.8 13837acc60 Implement BAT-006: portfolio-hub ledger integration (REQ-017~019)
- REQ-017: LedgerPort contract (application/ledger_port.py) + portfolio-hub
  adapter + in-memory stub (adapters/ledger/), TREX_PORTFOLIO_HUB_* config
- REQ-018: fill→ledger recording in execution loop; FillStatus carries
  execution_id (deterministic synth) + fee; paper/kis adapters updated
- REQ-019: ledger outbox + retry worker (application/ledger_outbox.py),
  correlation_id idempotency, outcome vocabulary; 002_create_ledger_outbox.sql
- Tests: in-memory/portfolio-hub ledger, execution ledger hook, outbox,
  domain import sweep

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 22:57:31 +09:00
genichinandClaude Opus 4.8 6277d610ea Add dcy-005 Discovery (draft): portfolio-hub asset snapshot read API
- new-discovery dcy-005: read-direction follow-up of dcy-004 (deferred
  get_assets/get_portfolios). trex-core exposes portfolio-hub asset snapshot
  as a read API, returning buy candidates with slot-occupied symbols filtered
  out (slot overlay) and an empty list when no slots remain.
- 6 open questions pinned: snapshot shape, freshness/cache, core-proxy policy,
  in-flight overlay (ledger outbox eventual consistency), availability degrade,
  empty-list semantics.
- Link dcy-004 후속 Discovery 참조 → dcy-005; add dcy-005 to discovery index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 22:51:30 +09:00
genichinandClaude Opus 4.8 01a51d0c16 Advance dcy-004 ledger slice: confirm Discovery, draft+approve REQ-017~020, draft BAT-006
- confirm-discovery dcy-004: draft→confirmed (Confirmed By: Justin Ko),
  OQ-1~3 resolved, scope/R-1 accepted, portfolio-hub contract deferred to REQ/delivery
- draft-req: REQ-017 (LedgerPort + portfolio-hub adapter + stub), REQ-018
  (fill→ledger recording + FillStatus exec_id/fee), REQ-019 (ledger outbox
  durability + correlation_id idempotency), REQ-020 (baseline alignment);
  NFR-1~3 absorbed
- confirm-req: REQ-017~020 Proposed→Approved
- draft-batch: BAT-006 (standard) bundling REQ-017~020 from dcy-004
- Update SRS/Discovery/batches indexes

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 22:32:27 +09:00
genichinandClaude Opus 4.8 88f5af434b Resolve dcy-004 OQ-1~3 from trex-orbit reference
- OQ-1 asset_id: asset_id == portfolio_id — use the slot's portfolio_id
  directly as the ledger path param (orbit ledger.py / migration 003 /
  coordinator). No symbol mapping or asset lookup.
- OQ-2 durability: ledger outbox (work item) + retry loop, correlation_id
  {asset_id}:{order_id}:{execution_id} dedup, outcome vocabulary
  (completed/duplicate_completed/retryable_failure/conflict_blocked) —
  orbit LedgerWriter pattern; recording decoupled from slot transition.
- OQ-3 exec data: deterministic execution_id (KIS
  kis-daily-ccld:{ord_dt}:{brno}:{odno}:{tot_ccld_qty} / paper synth),
  fee via BrokerPort calculate_fee, tax default 0.

All dcy-004 open questions answered; R-2/R-4 resolved. Remaining gates
(scope-defer confirm, portfolio-hub contract data, Confirmed By) left for
confirm-discovery.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 19:44:00 +09:00
genichinandClaude Opus 4.8 b37b16be93 Add dcy-004 Discovery (draft): portfolio-hub ledger integration
Record fills to the portfolio-hub ledger (orbit post_ledger_trade pattern)
so external accounting/positions reflect trades. The slot already carries
portfolio_id but nothing consumes it; this closes a deferral not previously
made explicit in dcy-003. Scope: LedgerPort + portfolio-hub adapter + stub,
record on buy/sell fill, execution_id idempotency, failure retry/hold;
out of scope: non-trade transactions, asset sync, reconciliation. OQ-1
(asset_id source), OQ-2 (durability), OQ-3 (exec data source) left for
confirm-discovery; handoff held.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 19:30:38 +09:00
genichin ee4456e7fd update .env.example 2026-06-04 18:57:35 +09:00
genichinandClaude Opus 4.8 ac6061f510 Deliver BAT-005: KIS token Redis cache (REQ-016, minor-change)
Port the trex-orbit Redis token-cache pattern so the KIS access token
survives daemon restarts and is shared across processes, avoiding KIS
token-issuance rate limits. KISBroker._ensure_token now resolves L1
in-memory -> L2 cache -> issue, storing issued tokens back to the cache.

- adapters/broker/token_cache.py: TokenCache protocol + RedisTokenCache
  (key trex:broker:kis:{account_ref}:token, token+expiry+app_key suffix
  JSON, ex=ttl, best-effort with graceful fallback) + InMemoryTokenCache.
- kis.py: optional token_cache injection.
- runtime config/daemon: TREX_KIS_REDIS_URL wires a RedisTokenCache.
- pyproject: redis>=5.

Verification: 96 passed, ruff clean — cache hit avoids issuance, cache is
shared across instances (restart/multi-process survival), backend errors
fall back to issuance (no regression), and app_key-suffix mismatch
invalidates a stale cache. Tested deterministically with an in-memory
double (no Redis server required). Processed via the minor-change fast
path: REQ-016 -> Implemented, BAT-005 (batch-lite) -> release-candidate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 18:44:09 +09:00
genichinandClaude Opus 4.8 97d58318db Deliver BAT-004: broker execution + KIS adapter + durable handoff
Implement REQ-011~015 (dcy-003): the order-execution layer on top of the
BAT-002 slot-core daemon, connecting intents to real orders.
- application: BrokerPort (submit/poll_fill/cancel) + ExecutionService
  (claim -> submit -> poll -> transition -> rollback -> reconcile)
- adapters/broker: PaperBroker (deterministic async double) and KISBroker
  (KIS Open API: token, order-cash, inquire-daily-ccld, cancel; VTS sandbox
  tr_ids; live account gated behind allow_live)
- persistence: option-A execution queue (find_pending_for_dispatch FOR
  UPDATE SKIP LOCKED, mark_dispatched idempotency guard, clear_dispatch)
- runtime: background execution loop in the daemon lifespan + startup
  reconcile; config selects paper|kis

Verification (real KIS VTS 모의투자 + PostgreSQL): 92 passed, ruff clean,
domain import sweep shows zero broker/web/db deps, buy->holding /
sell->closed / reject->idle, idempotent dispatch (exactly one order),
reconcile after crash creates no duplicate order, KIS sandbox token+submit
round-trip, and a daemon E2E through the background loop. Align the four
baseline docs. BAT-004 -> release-candidate; REQ-011~015 -> Implemented.

KIS live-account go-live, partial-fill accrual, option-B outbox, connection
pooling, and the safety floor remain deferred to follow-up Discoveries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 17:46:17 +09:00
genichinandClaude Opus 4.8 d60d720bc7 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>
2026-06-04 16:40:23 +09:00
genichinandClaude Opus 4.8 575ba9f513 Deliver BAT-003: daemon .env loading (REQ-010, minor-change)
DaemonConfig.from_env() now best-effort loads a .env file (find_dotenv
usecwd, load_dotenv override=False) so operators can manage daemon env
vars via .env, with real OS env taking precedence. Add python-dotenv
dependency, gitignore .env, ship .env.example, and add config tests
(load / OS-env precedence / absence regression / missing-DSN guard).

Verification: 78 passed, ruff clean, .env ignored + .env.example tracked,
and a .env-only DaemonConfig smoke. Processed via the minor-change fast
path: REQ-010 (Configuration) -> Implemented, BAT-003 (batch-lite,
no design) -> release-candidate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 14:56:42 +09:00
genichinandClaude Opus 4.8 a4e263c8e7 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>
2026-06-04 13:46:08 +09:00
genichinandClaude Opus 4.8 a44f9fddb7 Draft+approve REQ-005~009 from dcy-002 (slot-core daemon + API)
Decompose dcy-002 FR-1~FR-6 into five requirements and promote them to
Approved (gate passed; source dcy-002 confirmed):
- REQ-005 (Installation): slot-core daemon runtime + lifecycle/healthz
- REQ-006 (Data): PostgreSQL SlotRepository + schema + drift test
- REQ-007 (Interface): intent submission API + idempotency
- REQ-008 (Interface): read-only slot/capacity query API
- REQ-009 (Documentation): daemon/API/persistence baseline alignment

NFR-1/2/3 absorbed into REQ-006/007 acceptance. Update SRS index
(Next ID -> REQ-010, register, change log) and dcy-002 created-REQ refs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 11:12:34 +09:00
genichinandClaude Opus 4.8 346a580856 Add dcy-002 Discovery (confirmed): slot-core daemon + HTTP intent API
Second iteration scope: promote the slot pure-domain core to a long-lived
daemon exposing a versioned HTTP API for buy/sell strategy daemons, backed
by durable single-writer PostgreSQL persistence.

All open questions resolved and operator-confirmed:
- OQ-1 durability: synchronous commit + intent_id idempotency + durable
  intent_log seam; full async outbox deferred to the broker-execution
  Discovery.
- OQ-2 framework: FastAPI + uvicorn.
- OQ-3 endpoints: /v1 set (healthz, intents/buy, intents/sell,
  intents/{id}, slots, capacity); cancel/preallocate excluded.
- OQ-4 schema: trex-core-owned migrations keyed to dcy-001 Appendix A
  (orbit-v2 DDL as reference), archive excluded, drift test realizes the
  DB-side check dcy-001 OQ-2 deferred.

Scope defers broker execution, safety floor, and strategy daemons to a
follow-up Discovery. Confirmed By Justin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 10:56:08 +09:00
genichinandClaude Opus 4.8 20498aa4ce Deliver BAT-001: bootstrap trex-core + port slot pure domain
Implement REQ-001~004 (dcy-001): scaffold the trex-core package
(pyproject, trex_core/, tests/), port the slot pure domain into
trex_core.domain.slot with import rewrites, add the EXPECTED_SLOT_FIELDS
contract guard (test_contract), and port the state/service unit tests.

Verification: 56 passed, ruff clean, import sweep shows zero external
deps, public __all__ exposes no infra symbols, contract negative case
reproduced. Align project-structure/runtime-flows baselines to the real
tree. Sync SDLC tracking: REQ-001~004 → Implemented, BAT-001 →
release-candidate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 00:16:07 +09:00
genichinandClaude Opus 4.8 8b23b89977 Confirm dcy-001: promote slot-domain Discovery to confirmed
Resolve scope/toolchain CONFIRM items (operator-confirmed), check off
remaining handoff items, and flip Freeze flags (Handoff 승인, Ready true,
Confirmed By Justin). Update discovery index row to confirmed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 22:19:30 +09:00
genichinandClaude Opus 4.8 f44b84465a Resolve dcy-001 OQ-1: adopt trex_core.domain.slot namespace
Record the OQ-1 decision (trex_core.domain.slot over app.domain.slot) in
dcy-001 and propagate the planned package path app/ -> trex_core/ across
the structure baseline and bootstrap seed (dist name trex-core).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 12:57:52 +00:00
genichinandClaude Opus 4.8 431c1a7bd2 Inline slot column contract in dcy-001, drop temp/plan.md references
Remove all references to the gitignored temp/plan.md draft and embed the
Slot column contract it depended on as Appendix A, so the Discovery stays
self-contained after temp/ is deleted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 12:48:01 +00:00
genichinandClaude Opus 4.8 0c29a32487 Add dcy-001 Discovery: trex-core base + slot pure-domain migration
First real Discovery after baseline bootstrap. Defines scope, FR/NFR,
risks, and success criteria for bootstrapping the trex-core Python
project and migrating the slot pure domain (no persistence/CLI).
Open questions OQ-1 (package namespace) and OQ-2 (column-contract
anchoring) left for confirm-discovery; handoff held.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 12:42:41 +00:00
genichinandClaude Opus 4.8 b40e569537 Bootstrap StagePilot baseline for slot domain migration
Initialize baseline seed, four baseline docs (project-structure,
runtime-flows, interface-contract, data-model), and the active
discovery/srs/batches/releases indexes. Content derived from the
trex-orbit slot pure-domain migration plan (trex-core as a new base,
pure domain only).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 09:47:14 +00:00
genichinandClaude Opus 4.8 2bb2db1a72 Add SDLC governance scaffolding and Claude/GitHub skills
Add CLAUDE.md governance instructions, .claude command definitions,
and .github skill/instruction set for the Agile iterative SDLC flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 08:56:54 +00:00
genichin a9f99f90fd Merge commit '9339d3d503a273316eafa8877032fe978eefd8a1' as '.stage-pilot' 2026-06-03 08:56:02 +00:00
genichin 9339d3d503 Squashed '.stage-pilot/' content from commit 2c0510c
git-subtree-dir: .stage-pilot
git-subtree-split: 2c0510c68add43c50adcdedb30c174e68e730395
2026-06-03 08:56:02 +00:00
genichin 1740bd536a first commit 2026-06-03 08:54:16 +00:00