fix: align warning-case blocking semantics across reconcile paths
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
45a5e4157d
commit
310b6f6dec
@@ -17,6 +17,7 @@ from trex_core.application.account_snapshot import AccountSnapshotUnavailable
|
||||
from trex_core.application.broker_port import BalanceItem
|
||||
from trex_core.application.messaging import RpcRequest, RpcResponse
|
||||
from trex_core.application.portfolio import (
|
||||
BLOCKING_RECONCILE_CASES,
|
||||
PauseStore,
|
||||
ReconcileWarningStore,
|
||||
SnapshotStore,
|
||||
@@ -270,15 +271,16 @@ def make_slots_rpc_handler(
|
||||
for sid in warned_slot_ids:
|
||||
info = warn_store.get_warning_info(sid)
|
||||
if info is None:
|
||||
continue
|
||||
raise RuntimeError(f"missing warning info for slot_id={sid}")
|
||||
raw_codes = info.get("case_codes")
|
||||
if isinstance(raw_codes, list):
|
||||
codes = {str(code) for code in raw_codes if code}
|
||||
else:
|
||||
case_code = str(info.get("case_code", ""))
|
||||
codes = {case_code} if case_code else set()
|
||||
if codes:
|
||||
warning_cases_by_slot[str(sid)] = codes
|
||||
if not codes:
|
||||
raise RuntimeError(f"empty warning cases for slot_id={sid}")
|
||||
warning_cases_by_slot[str(sid)] = codes
|
||||
except Exception: # noqa: BLE001
|
||||
_log.exception("warn_store warning query failed — fail-closed")
|
||||
return RpcResponse(payload={
|
||||
@@ -290,7 +292,10 @@ def make_slots_rpc_handler(
|
||||
"reconcile warning store unavailable; "
|
||||
"returning no slots (fail-closed)"
|
||||
),
|
||||
"excluded_slots": {"reconcile_quantity_mismatch": 0},
|
||||
"excluded_slots": {
|
||||
"reconcile_quantity_mismatch": 0,
|
||||
"active_reconcile_warning_cases": {},
|
||||
},
|
||||
})
|
||||
|
||||
# Build merged slot rows (REQ-074)
|
||||
@@ -314,7 +319,8 @@ def make_slots_rpc_handler(
|
||||
included: list[tuple[object, dict]] = []
|
||||
for slot, row in zip(slots, slot_rows, strict=True):
|
||||
blocked_holding = (
|
||||
slot.status.value == "holding" and bool(row.get("reconcile_warned"))
|
||||
slot.status.value == "holding"
|
||||
and bool(set(row.get("reconcile_warning_cases", [])) & BLOCKING_RECONCILE_CASES)
|
||||
)
|
||||
if blocked_holding:
|
||||
excluded_count += 1
|
||||
@@ -432,7 +438,7 @@ def make_slots_rpc_handler(
|
||||
if warn_store is not None:
|
||||
base_payload["excluded_slots"] = {
|
||||
"reconcile_quantity_mismatch": excluded_count,
|
||||
"reconcile_warning_cases": excluded_case_counts,
|
||||
"active_reconcile_warning_cases": excluded_case_counts,
|
||||
}
|
||||
return RpcResponse(payload=base_payload)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user