INNER CODE UNIT · Python
_protection_version_guard
qrak/LLM_trader · src/app.py:582
def _protection_version_guard(
self,
decision: TradeDecision | None,
version_before: str | None,
version_after: str | None,
) -> str | None:
"""Refuse an UPDATE computed against a protection set that was replaced.
Only meaningful when BOTH reads returned a revision (the executor's additive
``protection_version``): a different value means the protection was replaced while
the model was working, so the UPDATE describes a state that no longer exists. A
missing revision is not treated as "unchanged" — it is "unversioned", and the
wave-1 loosening guard remains the substitute (see ``_protection_guard_note``).
"""
if decision is None or str(getattr(decision, "action", "") or "").upper() != "UPDATE":
return None
if not version_before or not version_after:
return None