Files
StarPilot/openpilot/starpilot/spot_monitor/actions.py
T
firestar5683 9d298304c3 Vision
Implement vision annotation observations, inference and preferences through a dedicated runtime owner.
2026-10-14 20:02:39 -05:00

16 lines
773 B
Python

"""One exact-source, parked-authorized V-ASM preference replacement."""
from collections.abc import Callable
from openpilot.starpilot.saved_document import WriteResult, commit_exact
from openpilot.starpilot.spot_monitor.preferences import KEY, MAX_BYTES, decode, encode
def commit(params, raw: bytes, expected: bytes | None, authorized: Callable[[], bool]) -> WriteResult:
"""Never rewrite a missing/invalid source on read; reset writes canonical Off."""
preferences = decode(raw) if type(raw) is bytes else None
if preferences is None or encode(preferences) != raw:
return WriteResult(False, False)
return commit_exact(params, key=KEY, max_bytes=MAX_BYTES, raw=raw, expected=expected,
authorized=authorized, temp_prefix=".tmp_vasm_")