# BAT-013 Implementation - Status: completed - Batch: BAT-013 ## Plan Summary - 순서: REQ-049 동적 큐명/declare_topology → REQ-050 exchange/binding/routing → REQ-048 TOML 로더/--config → REQ-051 baseline. 각 단계 단위 green 후 진행. default 하위호환 회귀 우선. ## Changed Files - (구현 시 기록) ### 신규 (예정) - `tests/runtime/test_instance_config.py` (REQ-048) - `tests/adapters/messaging/test_instance_topology.py` (REQ-049/050) - 인스턴스 TOML 예시(`config/instance.example.toml`, 추적) (REQ-048) ### 수정 (예정) - `trex_core/adapters/messaging/topology.py` (동적 큐명 + DIRECT/BROADCAST + routing key) - `trex_core/adapters/messaging/rabbitmq.py` (declare_topology(instance_key) + exchange/binding) - `trex_core/runtime/config.py` (DaemonInstanceConfig + from_toml + from_config) - `trex_core/runtime/daemon.py` (--config argparse + instance_key 큐 적용) - `.gitignore` (인스턴스 TOML) - baseline 3문서 (REQ-051) ## Changed Files (실제) - 신규: `config/instance.example.toml`(추적), `tests/runtime/test_instance_config.py`, `tests/adapters/messaging/test_instance_topology.py`. - 수정: `topology.py`(동적 큐명 빌더 + DEFAULT_INSTANCE_KEY/DIRECT_EXCHANGE/BROADCAST_EXCHANGE + direct_routing_key), `rabbitmq.py`(declare_topology(instance_key) + exchange/binding/control dual + import 정리), `config.py`(DaemonInstanceConfig+from_toml+from_config, DaemonConfig.instance_key), `daemon.py`(--config argparse main + per-instance 큐 구독 + declare_topology(instance_key)), `.gitignore`(인스턴스 TOML), baseline 3문서(REQ-051). ## Execution Log 1. REQ-049 동적 큐명(default 리터럴) + declare_topology(instance_key) + daemon per-instance consume → 빌더 단위 + messaging 회귀 green. 2. REQ-050 trex.direct/trex.broadcast exchange + binding + routing key → 인프라 게이트(directed 격리 + broadcast dual) green. 3. REQ-048 DaemonInstanceConfig.from_toml + from_config 병합 + --config argparse + .gitignore + example TOML → 로더 단위 + `--config` 누락 subprocess 종료 green. 4. REQ-051 baseline 3문서 정합. 5. 전체 회귀: 단위 271 passed / 30 skipped, ruff clean. 6. 인프라 게이트(PG+RabbitMQ): 301 passed (directed 라우팅 격리 S-2 + broadcast dual S-3 + default 무회귀 S-4 포함). ## Validation - 단위: `pytest -q --deselect ...::test_sandbox_token_and_submit` → 271 passed / 30 skipped. - 인프라 게이트: `TREX_RABBITMQ_TEST_URL=... TREX_POSTGRESQL_TEST_DSN=... pytest -q` → 301 passed. - lint: `ruff check trex_core tests` → All passed. ## Remaining Risks - R-1(declare_topology 변경 회귀): default=리터럴 큐명 하위호환으로 기존 messaging 테스트 무변경 — 301 passed 로 확인(FR-5/NFR-1). - R-2(old 큐 잔류): 운영 자연 소멸(OQ-1), 코드 무관. - (이월, 비차단) 실 2-인스턴스 동시 기동 manual e2e: directed 격리·broadcast 는 인프라 게이트 통합 테스트로 검증됨. 실 배포 시 다중 인스턴스 운영 시점 확인.