fix(broker): enforce operator broker truth boundary

This commit is contained in:
Hermes Agent
2026-07-15 08:07:21 +09:00
parent 1b63e79edc
commit 216e462df4
19 changed files with 603 additions and 35 deletions
@@ -89,6 +89,19 @@ class InMemorySlotRepository:
if s.instance_key == instance_key and s.status is SlotState.HOLDING
]
def find_managed_slot_by_symbol(self, instance_key: str, symbol: str) -> Optional[Slot]:
candidates = [
s for s in self._slots.values()
if s.instance_key == instance_key and s.symbol == symbol
]
# PostgreSQL parity: updated_at DESC NULLS LAST, slot_id ASC.
candidates.sort(key=lambda s: (
s.updated_at is None,
-s.updated_at.timestamp() if s.updated_at is not None else 0,
str(s.slot_id),
))
return candidates[0] if candidates else None
def reconcile_universe(
self, instance_key: str, universe: dict[str, str],
*, allow_retire: bool = True,
+7
View File
@@ -72,6 +72,13 @@ class SlotRepository(Protocol):
reconcile; safety-sell / kill-switch sweeps)."""
...
def find_managed_slot_by_symbol(self, instance_key: str, symbol: str) -> Optional[Slot]:
"""Return one deterministic managed slot for exact instance+symbol.
Read-only reconciliation triage; this must not imply remediation.
"""
...
def reconcile_universe(
self, instance_key: str, universe: dict[str, str],
*, allow_retire: bool = True,