# req-061: intent 계약 자산(portfolio_id) 키 통일 + 중복/무효 규칙 - Status: Proposed - Type: Interface - Priority: High - Owner: project maintainers ## Intent - 자산 중심 모델에서 매수·매도 신호를 모두 자산(portfolio_id)으로 식별하도록 intent 계약을 통일하고, 슬롯이 자산 1:1 영구이므로 `sell-by-slot_id` 노출을 폐기한다. (dcy-020 FR-7/NFR-4) ## Requirement - 매수·매도 intent 를 모두 `portfolio_id`(자산) 키로 식별한다. 매수 = 해당 자산 슬롯 활성화(`inactive→pending_buy`), 매도 = 비활성화(`holding→pending_sell`). **`sell-by-slot_id` 는 폐기**한다. 중복/무효 신호 규칙: 이미 활성(`pending_buy`/`holding`/`pending_sell`)인 자산에 매수 신호 → 멱등 거부(`already_active`); 보유 아닌 자산에 매도 신호 → 거부(`not_holding`). `intent_id` 멱등(intent_log)은 보존한다. 계약 변경은 외부 전략 모듈을 깨뜨리므로 cutover/버전 절차를 명시한다(NFR-4). ## Acceptance Criteria 1. Given 매도 신호, When `portfolio_id` 로 제출, Then 해당 자산 슬롯이 `pending_sell` 로 전이하고 `slot_id` 없이 처리된다. 2. Given 이미 holding 인 자산, When 매수 신호, Then `already_active` 로 멱등 거부된다. 3. Given 보유하지 않은 자산, When 매도 신호, Then `not_holding` 으로 거부된다. 4. Given 같은 `intent_id` 재전송, When 처리, Then 슬롯 중복 전이 없이 최초 결정과 동일 응답(멱등). ## Impacted Area - Docs: docs/runtime-flows.md(intent 흐름), docs/interface-contract.md(메시지 계약) - Modules: trex_core/application/intents.py, 메시지 핸들러/스키마 - Tests: tests/application/test_messaging_intent_consumer.py, tests/application/test_*intent*.py ## Notes - 기존 REQ-007(intent API) 재정의 change-req 동반(sell-by-slot_id 폐기·자산 키 통일). NFR-4(전략 계약 호환): 외부 전략 모듈 동시 전환 또는 한시적 하위호환 — REQ/배치 cutover 에서 명시. - 출처: dcy-020 FR-7, NFR-4. ## Change Log ### CHG-20260610-01 - Date: 2026-06-10 - Author: Justin Ko #### Change Summary - dcy-020 FR-7/NFR-4 로부터 최초 생성(Proposed). intent 자산(portfolio_id) 키 통일 + sell-by-slot_id 폐기 + already_active/not_holding. #### Intent - 매수·매도 신호를 자산 키로 통일하는 계약 변경을 backlog 정규화. #### Acceptance Criteria Delta - Added: 매도 자산키/already_active/not_holding/intent_id 멱등 4개 기준 - Updated: 없음 - Removed: 없음 #### Impacted Area Delta - Docs: docs/runtime-flows.md, docs/interface-contract.md - Modules: application/intents.py, 메시지 핸들러/스키마 - Tests: test_messaging_intent_consumer.py, intent 테스트 #### Delivery Trace Delta - Batches: none - Releases: none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no (REQ-007 재정의 change-req 로 기존 폐기) - Status Recommendation: keep-current - Follow-up Action: confirm-req. NFR-4 외부 전략 계약 cutover 명시. #### Validation Plan - 자산 키 매도/거부 규칙/멱등 단위·통합 테스트 green.