fix(intents): isolate alarm context lookup and sanitize alarm failure logs

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-08-26 05:02:19 +00:00
committed by GitHub
co-authored by genichin
parent 5dd3d57f86
commit 1ca9e60c98
9 changed files with 249 additions and 18 deletions
+20 -11
View File
@@ -183,20 +183,11 @@ class IntentService:
intent.intent_id, decision.status, decision.slot_id, decision.reason
)
if decision.status == "rejected" and decision.reason == "reconcile_warned":
slot = (
self._repo.fetch_slot(intent.slot_id)
if intent.slot_id is not None
else (
self._repo.find_slot_by_portfolio(self._instance_key, intent.portfolio_id)
if intent.portfolio_id
else None
)
)
self._publish_reconcile_warned_rejection_alarm(
intent_id=intent.intent_id,
intent_type="buy",
strategy_id=intent.strategy_id,
slot=slot,
slot=self._resolve_buy_alarm_slot(intent),
)
return decision
@@ -221,10 +212,28 @@ class IntentService:
intent_id=intent.intent_id,
intent_type="sell",
strategy_id=intent.sell_strategy_id,
slot=self._repo.fetch_slot(intent.slot_id),
slot=self._resolve_sell_alarm_slot(intent),
)
return decision
def _resolve_buy_alarm_slot(self, intent: BuyIntent) -> Any:
try:
if intent.slot_id is not None:
return self._repo.fetch_slot(intent.slot_id)
if intent.portfolio_id:
return self._repo.find_slot_by_portfolio(
self._instance_key, intent.portfolio_id
)
except Exception: # noqa: BLE001 - optional alarm context lookup
return None
return None
def _resolve_sell_alarm_slot(self, intent: SellIntent) -> Any:
try:
return self._repo.fetch_slot(intent.slot_id)
except Exception: # noqa: BLE001 - optional alarm context lookup
return None
def _publish_reconcile_warned_rejection_alarm(
self,
*,