feat(perception): integrate calibrated operator pipeline
Add calibrated K1 projection, recorded and near-live perception qualification, unified Rerun operator layers, bounded replay admission, audited viewer controls, worker experiments, and lab evidence.
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import asyncio
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
import k1link.device_plugins.xgrids_k1.ble.wifi_provisioning as wifi_module
|
||||
from k1link.device_plugins.xgrids_k1.ble.wifi_provisioning import (
|
||||
FRAME_LENGTH,
|
||||
build_wifi_provisioning_frame,
|
||||
parse_wifi_status,
|
||||
read_wifi_status_once,
|
||||
)
|
||||
|
||||
|
||||
@@ -70,3 +76,55 @@ def test_parse_wifi_status_ap_baseline() -> None:
|
||||
def test_parse_wifi_status_rejects_short_frame() -> None:
|
||||
with pytest.raises(ValueError, match="at least 51 bytes"):
|
||||
parse_wifi_status(bytes(50))
|
||||
|
||||
|
||||
def test_read_wifi_status_once_reads_only_and_returns_current_dhcp_address(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
value = bytearray(54)
|
||||
value[0] = 11
|
||||
value[1:12] = b"WIFI_CLIENT"
|
||||
value[33] = 4
|
||||
value[34:38] = bytes((10, 255, 254, 77))
|
||||
value[50] = 1
|
||||
characteristic = SimpleNamespace(
|
||||
uuid=wifi_module.STATUS_CHARACTERISTIC_UUID,
|
||||
service_uuid=wifi_module.SERVICE_UUID,
|
||||
properties=["read"],
|
||||
)
|
||||
service = SimpleNamespace(uuid=wifi_module.SERVICE_UUID)
|
||||
|
||||
class FakeServices:
|
||||
def get_service(self, uuid: str) -> object | None:
|
||||
return service if uuid == wifi_module.SERVICE_UUID else None
|
||||
|
||||
def get_characteristic(self, uuid: str) -> object | None:
|
||||
return characteristic if uuid == wifi_module.STATUS_CHARACTERISTIC_UUID else None
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self, _device: object, **_kwargs: object) -> None:
|
||||
self.services = FakeServices()
|
||||
self.name = "XGR-K1"
|
||||
self.write_calls = 0
|
||||
|
||||
async def __aenter__(self) -> Any:
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_args: object) -> None:
|
||||
return None
|
||||
|
||||
async def read_gatt_char(self, _characteristic: object) -> bytes:
|
||||
return bytes(value)
|
||||
|
||||
async def write_gatt_char(self, *_args: object, **_kwargs: object) -> None:
|
||||
self.write_calls += 1
|
||||
raise AssertionError("status refresh must not write a BLE characteristic")
|
||||
|
||||
monkeypatch.setattr(wifi_module, "discovered_device", lambda _uuid: object())
|
||||
monkeypatch.setattr(wifi_module, "BleakClient", FakeClient)
|
||||
|
||||
result = asyncio.run(read_wifi_status_once("synthetic-corebluetooth-uuid"))
|
||||
|
||||
assert result["operation"] == "single_reviewed_wifi_status_read"
|
||||
assert result["write_performed"] is False
|
||||
assert result["status"]["ipv4"] == "10.255.254.77"
|
||||
|
||||
Reference in New Issue
Block a user