mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 13:33:42 +08:00
9d298304c3
Implement vision annotation observations, inference and preferences through a dedicated runtime owner.
16 lines
773 B
Python
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_")
|