2.1 KiB
2.1 KiB
BAT-037 Design
- Status: confirmed
- Batch: BAT-037
Architecture Summary
make_slots_rpc_handler에max_active_slots: Optional[int] = None파라미터를 추가하고, 응답 생성 시available_slots를 계산해 포함한다.daemon.py의 핸들러 wiring 에max_active_slots=self.config.max_active_slots를 전달한다.- 계산:
max_active_slots가 None 이면null, 설정 시max(0, M − slot_repo.count_active(instance_key)). SlotService.compute_slot_capacity는 SlotService 인스턴스가 필요하고 slots 핸들러에는 repo 만 주입되어 있으므로,count_active를 직접 호출하는 인라인 계산을 사용한다.
Changed Areas
- Modules:
trex_core/application/messaging_handlers.py—make_slots_rpc_handler시그니처 + 응답 구성trex_core/runtime/daemon.py—_slots_rpc_loop핸들러 wiring
- Tests:
tests/application/test_slots_handler.py— AC-3 키 집합, AC-6 값 검증
- Docs:
docs/interface-contract.md는 REQ-075 소관이므로 이번 배치에서 갱신하지 않음
Key Decisions
SlotService대신slot_repo.count_active직접 호출 — slots 핸들러에 SlotService 가 주입되지 않으며, count_active 는 repo 레벨에서 단일 쿼리로 처리 가능. 의존성을 늘리지 않는다.available_slots = nullwhenmax_active_slots is None— "제한 없음"을 명시적으로 표현. 소비 측(orb-v1)은 null 을 "제한 없음"으로 처리.available_slots = max(0, M − count_active)— active count 가 M 을 초과하는 경우(수동 DB 조작 등)는 0 으로 클램프.
Edge Cases
max_active_slots미설정(None):available_slots = null반환.- active > max_active_slots:
available_slots = 0(클램프). count_active쿼리 실패: 예외를 상위로 전파 — 응답 자체가 실패하므로 hint 만 null 로 fallback 하지 않는다(일관성 유지).
Architecture Impact
- none (runtime-flows 흐름 변경 없음, 응답 필드 추가만)
Reference Doc Update Plan
- project-structure.md: none
- runtime-flows.md: none