feat(ledger): quiet idle outbox polling

This commit is contained in:
Hermes Agent
2026-09-20 21:57:30 +09:00
parent 62e4f57c2b
commit a2be76b199
14 changed files with 437 additions and 15 deletions
@@ -259,6 +259,7 @@ def make_slots_rpc_handler(
watchdog_store: Optional[WatchdogStore] = None,
watchdog_timeout_sec: int = 120,
ledger_outbox=None,
ledger_outbox_metrics_reader=None,
max_active_slots: Optional[int] = None,
strategy_state_store=None,
broker_quantity_reader: Optional[SlotsBrokerQuantityReader] = None,
@@ -512,6 +513,23 @@ def make_slots_rpc_handler(
)
if health_payload:
base_payload["broker_balance_health"] = health_payload
if spy:
unavailable_metrics = {
"available": False,
"scope": "process_lifetime",
"instance_key": instance_key,
"reason": "ledger_outbox_metrics_unavailable",
}
if ledger_outbox_metrics_reader is None:
base_payload["ledger_outbox_metrics"] = unavailable_metrics
else:
try:
metrics = ledger_outbox_metrics_reader.metrics_snapshot()
if not isinstance(metrics, dict):
raise TypeError("metrics snapshot must be a dict")
base_payload["ledger_outbox_metrics"] = metrics
except Exception: # noqa: BLE001 - status response must stay available
base_payload["ledger_outbox_metrics"] = unavailable_metrics
if warn_store is not None:
base_payload["excluded_slots"] = {
"reconcile_quantity_mismatch": excluded_count,