feat: add messaging transport rollout
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# req-021: messaging 토폴로지 + 메시지 계약 매핑
|
||||
|
||||
- Status: Proposed
|
||||
- Status: Implemented
|
||||
- Type: Integration
|
||||
- Priority: High
|
||||
- Owner: project maintainers
|
||||
@@ -76,3 +76,69 @@
|
||||
|
||||
#### Validation Plan
|
||||
- stub 어댑터 통합테스트로 RPC 매핑·이벤트 routing key 필터링·매핑 원칙을 검증.
|
||||
|
||||
### CHG-20260605-02
|
||||
- Date: 2026-06-05
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
- Status 변경: Proposed -> Approved. confirm-req 승인 게이트 통과.
|
||||
|
||||
#### Intent
|
||||
- messaging 토폴로지 + 메시지 계약 매핑을 delivery input 으로 승인.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
- Added/Updated/Removed: 없음
|
||||
|
||||
#### Impacted Area Delta
|
||||
- Docs/Modules/Tests: 없음
|
||||
|
||||
#### Delivery Trace Delta
|
||||
- Batches:
|
||||
- none
|
||||
- Releases:
|
||||
- none
|
||||
|
||||
#### Revalidation Impact
|
||||
- Reverification Needed: no
|
||||
- Existing Implementation Invalidated: no
|
||||
- Status Recommendation: Approved
|
||||
- Follow-up Action: REQ-022/023/025 와 함께 batch 편성(통신 단절 R-5 회피)
|
||||
|
||||
#### Validation Plan
|
||||
- 기존 Acceptance Criteria 로 batch delivery 에서 검증.
|
||||
|
||||
### CHG-20260605-03
|
||||
- Date: 2026-06-05
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
- Status 변경: Approved -> Implemented. BAT-007 release-candidate verification evidence 기반.
|
||||
|
||||
#### Intent
|
||||
- messaging 토폴로지 + 메시지 계약 매핑 구현과 검증 evidence 확보 후 구현 완료 상태로 동기화.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
- Added/Updated/Removed: 없음
|
||||
|
||||
#### Impacted Area Delta
|
||||
- Docs/Modules/Tests: 없음
|
||||
|
||||
#### Delivery Trace Delta
|
||||
- Batches:
|
||||
- BAT-007 (release-candidate)
|
||||
- Releases:
|
||||
- none
|
||||
|
||||
#### Revalidation Impact
|
||||
- Reverification Needed: no
|
||||
- Existing Implementation Invalidated: no
|
||||
- Status Recommendation: Implemented
|
||||
- Follow-up Action: release 단계는 별도 진행
|
||||
|
||||
#### Validation Plan
|
||||
- AC-1: tests/adapters/messaging/test_rabbitmq_transport.py::test_declare_topology_creates_core_entities.
|
||||
- AC-2: tests/application/test_messaging_snapshot_consumer.py + tests/adapters/messaging/test_rabbitmq_transport.py::test_rpc_roundtrip.
|
||||
- AC-3: tests/application/test_messaging_intent_consumer.py + test_messaging_event_publisher.py 조합.
|
||||
- AC-4: tests/application/test_messaging_event_publisher.py::test_event_for_strategy_a_does_not_reach_strategy_b_queue + tests/adapters/messaging/test_rabbitmq_transport.py::test_event_publish_and_per_strategy_consume.
|
||||
- AC-5: tests/adapters/messaging/test_topology.py.
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
# req-022: messaging transport 포트 + RabbitMQ 어댑터 + stub + sync+thread daemon
|
||||
|
||||
- Status: Implemented
|
||||
- Type: Integration
|
||||
- Priority: High
|
||||
- Owner: project maintainers
|
||||
|
||||
## Intent
|
||||
- 메시징 접근을 application 경계의 transport 포트로 추상화하고, `pika`(동기) RabbitMQ 어댑터와 결정론 stub 을 adapters 레이어에 격리해 도메인 순수성을 유지하면서 메시지 기반 통신을 가능하게 한다. uvicorn 제거 후 데몬을 sync+thread 런타임으로 재구성한다.
|
||||
|
||||
## Requirement
|
||||
- application 레이어에 `MessagingTransport` (또는 동등한) Protocol 을 정의해 publish/subscribe/RPC consume 진입점을 추상화한다.
|
||||
- 신규 `trex_core/adapters/messaging/` 패키지에 두 구현체를 둔다.
|
||||
- `RabbitMQTransport`: `pika`(동기) BlockingConnection 기반. consumer/publisher 스레드별 connection/channel 또는 `add_callback_threadsafe` 규약을 따른다(pika 는 thread-safe 가 아님).
|
||||
- `InMemoryTransport` (stub): 결정론 테스트용 in-process publish/subscribe/RPC.
|
||||
- 데몬을 sync+thread 런타임으로 재구성한다(dcy-006 OQ-5): consumer 스레드(intent RPC, prefetch=1 단일 FIFO; snapshot RPC) + 기존 execution/ledger 루프 스레드 + 이벤트 publisher(execution 루프가 자기 channel 로 발행). graceful shutdown 은 기존 `stop` event 패턴을 확장해 connection close 까지 포함한다.
|
||||
- pika 자동 재연결이 없는 특성을 보정하기 위해 connection drop 시 백오프 기반 재연결 루프를 직접 구현하고 REQ-024 degrade 정책과 연동한다.
|
||||
- `trex_core/domain` 은 transport/AMQP 의존 0 을 유지한다(NFR-1, import 스윕).
|
||||
|
||||
## Acceptance Criteria
|
||||
1. Given in-process `InMemoryTransport` stub, When 테스트가 publish/subscribe/RPC 진입점을 호출, Then 외부 broker 없이 메시지 송수신이 동작한다.
|
||||
2. Given `RabbitMQTransport`, When `TREX_RABBITMQ_URL` 로 broker 에 접속, Then connection/channel 이 열리고 declared 큐/익스체인지로 메시지 송수신이 가능하다(integration 수준, 인프라 미가용 시 skip 게이트 허용).
|
||||
3. Given 데몬 기동, When lifecycle 을 시작, Then intent RPC consumer 스레드, snapshot RPC consumer 스레드, execution/ledger 스레드가 동시에 동작하고, shutdown 시 `stop` event 후 모든 스레드와 connection 이 정상 종료된다(`uvicorn.run` 의존 0).
|
||||
4. Given broker connection 이 끊긴 상태, When 어댑터가 감지, Then 백오프 재연결을 직접 수행하고, REQ-024 degrade 정책(버퍼링 금지·보수적 중단)에 따라 신규 처리를 중단한다.
|
||||
5. Given 정적 import 스윕, When `trex_core/domain` 을 점검, Then `pika`/AMQP/`trex_core.adapters.messaging` 의존이 0 이다(NFR-1).
|
||||
|
||||
## Impacted Area
|
||||
- Docs: docs/project-structure.md(adapters/messaging 위치 + 런타임 스레드 구성), docs/runtime-flows.md(consumer 스레드/이벤트 publisher 흐름) — REQ-026 에서 정합.
|
||||
- Modules:
|
||||
- 신규 `trex_core/application/messaging.py`(`MessagingTransport` Protocol)
|
||||
- 신규 `trex_core/adapters/messaging/` (`rabbitmq.py`, `in_memory.py`)
|
||||
- 변경 `trex_core/runtime/daemon.py`(uvicorn 제거, consumer 스레드 추가, graceful shutdown 확장)
|
||||
- 변경 `trex_core/runtime/config.py` (`TREX_RABBITMQ_URL` 로딩; REQ-025 와 함께 `TREX_API_HOST`/`TREX_API_PORT` 폐기)
|
||||
- 영향 `trex_core/application/intents.py`, dcy-005 스냅샷 application 서비스 — transport-무관 포트로 호출되도록 재배선
|
||||
- Tests:
|
||||
- in-process stub 통합테스트(publish/subscribe/RPC)
|
||||
- RabbitMQ integration 테스트(`TREX_RABBITMQ_URL` 게이트, 미가용 시 skip)
|
||||
- 데몬 lifecycle 테스트(스레드 기동/종료)
|
||||
- `tests/domain/test_domain_import_sweep.py` 가 `pika`·`adapters.messaging` 추가 금지 prefix 로 가드
|
||||
|
||||
## Notes
|
||||
- 출처: dcy-006 FR-3, NFR-1, OQ-5, OQ-6.
|
||||
- NFR-1(도메인 순수성) 은 REQ-017 AC-4 와 동일한 패턴으로 본 REQ AC-5 에 흡수한다(별도 REQ 미승격).
|
||||
- HTTP 어댑터 제거와 `TREX_API_HOST/PORT` 폐기는 REQ-025 본문에서 책임진다(본 REQ 는 신규 transport 도입 범위).
|
||||
- 실 RabbitMQ broker 인스턴스/자격증명 provision 은 delivery/운영 작업으로 위임됨(DATA, 비차단).
|
||||
|
||||
## Change Log
|
||||
|
||||
### CHG-20260605-01
|
||||
- Date: 2026-06-05
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
- dcy-006 FR-3 로부터 최초 생성(Proposed). NFR-1(도메인 순수성) 흡수.
|
||||
|
||||
#### Intent
|
||||
- 메시징 transport 포트 + RabbitMQ 어댑터 + stub + sync+thread 데몬 재구성 backlog 정규화.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
- Added:
|
||||
- stub publish/sub/RPC, RabbitMQ integration, 데몬 lifecycle, 재연결+degrade 연동, 도메인 import 스윕 (총 5개 기준)
|
||||
- Updated:
|
||||
- 없음
|
||||
- Removed:
|
||||
- 없음
|
||||
|
||||
#### Impacted Area Delta
|
||||
- Docs:
|
||||
- docs/project-structure.md, docs/runtime-flows.md
|
||||
- Modules:
|
||||
- application/messaging.py, adapters/messaging/{rabbitmq,in_memory}, runtime/daemon.py, runtime/config.py
|
||||
- Tests:
|
||||
- in-process stub, RabbitMQ integration(게이트), 데몬 lifecycle, import 스윕
|
||||
|
||||
#### 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 후 batch 편성
|
||||
|
||||
#### Validation Plan
|
||||
- stub 기반 통합테스트 + RabbitMQ integration 테스트(미가용 시 skip) + import 스윕으로 검증.
|
||||
|
||||
### CHG-20260605-02
|
||||
- Date: 2026-06-05
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
- Status 변경: Proposed -> Approved. confirm-req 승인 게이트 통과.
|
||||
|
||||
#### Intent
|
||||
- messaging transport 포트 + RabbitMQ 어댑터 + stub + sync+thread daemon 재구성을 delivery input 으로 승인.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
- Added/Updated/Removed: 없음
|
||||
|
||||
#### Impacted Area Delta
|
||||
- Docs/Modules/Tests: 없음
|
||||
|
||||
#### Delivery Trace Delta
|
||||
- Batches:
|
||||
- none
|
||||
- Releases:
|
||||
- none
|
||||
|
||||
#### Revalidation Impact
|
||||
- Reverification Needed: no
|
||||
- Existing Implementation Invalidated: no
|
||||
- Status Recommendation: Approved
|
||||
- Follow-up Action: REQ-021/023/025 와 함께 batch 편성
|
||||
|
||||
#### Validation Plan
|
||||
- 기존 Acceptance Criteria 로 batch delivery 에서 검증.
|
||||
|
||||
### CHG-20260605-03
|
||||
- Date: 2026-06-05
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
- Status 변경: Approved -> Implemented. BAT-007 release-candidate verification evidence 기반.
|
||||
|
||||
#### Intent
|
||||
- MessagingTransport 포트 + RabbitMQ 어댑터 + stub + sync+thread daemon 재구성을 구현 완료 상태로 동기화.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
- Added/Updated/Removed: 없음
|
||||
|
||||
#### Impacted Area Delta
|
||||
- Docs/Modules/Tests: 없음
|
||||
|
||||
#### Delivery Trace Delta
|
||||
- Batches:
|
||||
- BAT-007 (release-candidate)
|
||||
- Releases:
|
||||
- none
|
||||
|
||||
#### Revalidation Impact
|
||||
- Reverification Needed: no
|
||||
- Existing Implementation Invalidated: no
|
||||
- Status Recommendation: Implemented
|
||||
- Follow-up Action: release 단계는 별도 진행
|
||||
|
||||
#### Validation Plan
|
||||
- AC-1: tests/adapters/messaging/test_in_memory_transport.py 5종.
|
||||
- AC-2: tests/adapters/messaging/test_rabbitmq_transport.py 5종 (실 RabbitMQ 통합).
|
||||
- AC-3: tests/runtime/test_daemon_no_http_surface.py::test_daemon_module_has_no_fastapi_or_uvicorn_import + Daemon 4 스레드 코드.
|
||||
- AC-4: RabbitMQTransport 재연결 백오프 코드 + tests/adapters/messaging/test_in_memory_transport.py::test_unavailable_transport_raises_on_publish_and_rpc.
|
||||
- AC-5: tests/domain/test_domain_import_sweep.py.
|
||||
Reference in New Issue
Block a user