fix: align warning-case blocking semantics across reconcile paths

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-12 13:28:40 +00:00
committed by GitHub
co-authored by genichin
parent 45a5e4157d
commit 310b6f6dec
5 changed files with 63 additions and 13 deletions
+21 -2
View File
@@ -29,6 +29,7 @@ from typing import Any, Callable, Optional
from uuid import UUID
from trex_core.application.alarm_emitter import AlarmEmitter
from trex_core.application.portfolio import BLOCKING_RECONCILE_CASES
from trex_core.application.ports import IntentStore
from trex_core.domain.slot import (
SlotAdmissionRejectedError,
@@ -270,6 +271,24 @@ class IntentService:
except Exception: # noqa: BLE001 - alarm path must not affect intent decision
pass
def _is_reconcile_trade_blocked(self, slot_id: str) -> bool:
if self._warn_store is None:
return False
if not self._warn_store.is_warned(slot_id):
return False
info = self._warn_store.get_warning_info(slot_id)
if info is None:
return True
raw_codes = info.get("case_codes")
if isinstance(raw_codes, list):
case_codes = {str(code) for code in raw_codes if code}
else:
case_code = str(info.get("case_code", ""))
case_codes = {case_code} if case_code else set()
if not case_codes:
return True
return bool(case_codes & BLOCKING_RECONCILE_CASES)
# ------------------------------------------------------------
def _dedup(self, intent_id: str, intent_type: str, payload: dict) -> Optional[IntentDecision]:
"""Return prior decision if intent_id already seen; else None (and reserve it)."""
@@ -339,7 +358,7 @@ class IntentService:
# those paths call SlotService.sell() directly.
if self._warn_store is not None:
try:
if self._warn_store.is_warned(str(slot.slot_id)):
if self._is_reconcile_trade_blocked(str(slot.slot_id)):
return IntentDecision(
intent.intent_id, "rejected", None, "reconcile_warned"
)
@@ -432,7 +451,7 @@ class IntentService:
# SlotService.sell() / transit_slot() directly without IntentService (OQ-B).
if self._warn_store is not None:
try:
if self._warn_store.is_warned(str(slot.slot_id)):
if self._is_reconcile_trade_blocked(str(slot.slot_id)):
return IntentDecision(
intent.intent_id, "rejected", None, "reconcile_warned"
)