feat(slots-rpc): available_slots capacity hint 추가 (BAT-037 / REQ-073 AC-6)

slots RPC 응답에 available_slots: int|null 포함.
max_active_slots 미설정 시 null, 설정 시 max(0, M-active).
16 tests passed (AC-6 신규 3개 포함), 423 전체 통과.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 10:28:29 +09:00
co-authored by Claude Sonnet 4.6
parent 8135dffb90
commit 6c24bd4c2c
6 changed files with 59 additions and 14 deletions
+11 -3
View File
@@ -177,6 +177,7 @@ def make_slots_rpc_handler(
watchdog_store: Optional[WatchdogStore] = None,
watchdog_timeout_sec: int = 120,
ledger_outbox=None,
max_active_slots: Optional[int] = None,
):
"""Build the RPC handler for `trex.slots.req` (REQ-073/074).
@@ -184,9 +185,10 @@ def make_slots_rpc_handler(
filter: "all"|"inactive"|"pending"|"holding"|"error" (default "all")
spy=true: watchdog not updated (operator view, REQ-034 CHG-01)
Response: {slots: [...], degraded: bool, reason: str|null, message: str|null}
Each slot row carries slot/core state + hub asset data + watchdog + overlay
flags (strategy fields excluded — REQ-074 AC-5).
Response: {slots: [...], available_slots: int|null, degraded: bool,
reason: str|null, message: str|null}
available_slots: capacity hint — null when uncapped, max(0, M-active) when capped
(REQ-073 AC-6). Does not replace the admission gate.
"""
def handler(req: RpcRequest) -> RpcResponse:
@@ -248,8 +250,14 @@ def make_slots_rpc_handler(
reason = reason_code.value if reason_code is not None else None
message = msg
if max_active_slots is not None and max_active_slots > 0:
available_slots = max(0, max_active_slots - slot_repo.count_active(instance_key))
else:
available_slots = None
return RpcResponse(payload={
"slots": slot_rows,
"available_slots": available_slots,
"degraded": degraded,
"reason": reason,
"message": message,
+1
View File
@@ -274,6 +274,7 @@ class Daemon:
watchdog_store=self.watchdog,
watchdog_timeout_sec=self.config.safety_sell.watchdog_timeout_sec,
ledger_outbox=self.outbox,
max_active_slots=self.config.max_active_slots,
)
transport.consume_rpc_forever(
topology.slots_queue(self.config.instance_key), handler, self.stop)