AC-0023: fail-closed intent warn-store; C-case-only verify clear; clear_failed on partial error
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
1179bdfe23
commit
49eb20bd51
@@ -271,8 +271,10 @@ class IntentService:
|
||||
return IntentDecision(
|
||||
intent.intent_id, "rejected", None, "reconcile_warned"
|
||||
)
|
||||
except Exception: # noqa: BLE001 - fail-open
|
||||
pass
|
||||
except Exception: # noqa: BLE001 - fail-closed: warn-store down → reject
|
||||
return IntentDecision(
|
||||
intent.intent_id, "rejected", None, "reconcile_warning_unavailable"
|
||||
)
|
||||
|
||||
# dcy-021: a buy on a HOLDING slot is a position-sizing increase.
|
||||
is_increase = slot.status is SlotState.HOLDING
|
||||
@@ -362,8 +364,10 @@ class IntentService:
|
||||
return IntentDecision(
|
||||
intent.intent_id, "rejected", None, "reconcile_warned"
|
||||
)
|
||||
except Exception: # noqa: BLE001 - fail-open
|
||||
pass
|
||||
except Exception: # noqa: BLE001 - fail-closed: warn-store down → reject
|
||||
return IntentDecision(
|
||||
intent.intent_id, "rejected", None, "reconcile_warning_unavailable"
|
||||
)
|
||||
|
||||
if slot.status is not SlotState.HOLDING:
|
||||
return IntentDecision(
|
||||
|
||||
@@ -664,22 +664,35 @@ def verify_slot_reconcile(
|
||||
match = hub_qty == broker_qty
|
||||
|
||||
if match:
|
||||
# AC-0023: clear C-case warnings for ALL holding slots with this symbol.
|
||||
# AC-0023: clear C-case warnings for ALL slots (any status) with this symbol.
|
||||
# Only rows with case_code='C' are touched; B-case (or other) rows are preserved.
|
||||
cleared_slots: list[str] = []
|
||||
try:
|
||||
for s in slot_repo.list_holding_slots(instance_key):
|
||||
if s.symbol == sym:
|
||||
sid_str = str(s.slot_id)
|
||||
warn_store.clear_warned(sid_str)
|
||||
store.set_warning(s.portfolio_id, False)
|
||||
cleared_slots.append(sid_str)
|
||||
for s in slot_repo.list_slots(instance_key):
|
||||
if s.symbol != sym:
|
||||
continue
|
||||
sid_str = str(s.slot_id)
|
||||
warn_info = warn_store.get_warning_info(sid_str)
|
||||
if warn_info is None or warn_info.get("case_code") != "C":
|
||||
continue
|
||||
warn_store.clear_warned(sid_str)
|
||||
store.set_warning(s.portfolio_id, False)
|
||||
cleared_slots.append(sid_str)
|
||||
_log.info(
|
||||
"verify: reconcile-warning cleared (C-case resolved) "
|
||||
"symbol=%s hub_qty=%d broker_qty=%d cleared_slots=%s",
|
||||
sym, hub_qty, broker_qty, cleared_slots,
|
||||
)
|
||||
except Exception: # noqa: BLE001
|
||||
_log.exception("verify: failed to clear_warned for symbol=%s", sym)
|
||||
_log.exception("verify: failed to clear C-case warned for symbol=%s", sym)
|
||||
return {
|
||||
"portfolio_id": portfolio_id,
|
||||
"slot_id": slot_id_str,
|
||||
"result": "clear_failed",
|
||||
"hub_qty": hub_qty,
|
||||
"broker_qty": broker_qty,
|
||||
"reason": "warn_store error during C-case clear — warnings NOT fully cleared",
|
||||
}
|
||||
return {
|
||||
"portfolio_id": portfolio_id,
|
||||
"slot_id": slot_id_str,
|
||||
|
||||
Reference in New Issue
Block a user