feat(k1): complete primary acquisition lifecycle

This commit is contained in:
DCCONSTRUCTIONS
2026-07-17 23:03:59 +03:00
parent 9d51080d2e
commit aa3680948f
66 changed files with 6093 additions and 544 deletions
+61 -5
View File
@@ -46,6 +46,8 @@ def test_xgrids_compatibility_profile_loads_exact_firmware_and_sources() -> None
profile = LOADER.load_compatibility_profile()
assert profile["profile_id"] == "xgrids.lixelkity-k1.fw-3.0.2.direct-lan.v1"
assert profile["scope"]["vendor"] == "XGRIDS"
assert profile["scope"]["model"] == "LixelKity K1"
assert profile["scope"]["firmware"] == {"match": "exact", "version": "3.0.2"}
assert profile["scope"]["topology"] == "direct-lan"
assert LOADER.matches_target(profile, firmware="3.0.2", topology="direct-lan")
@@ -67,9 +69,9 @@ def test_xgrids_compatibility_profile_keeps_evidence_levels_independent() -> Non
"physical_verified": True,
"write_enabled": False,
}
raw_status = {
decoded_status = {
"observed": True,
"decoded": False,
"decoded": True,
"replay_verified": False,
"physical_verified": True,
"write_enabled": False,
@@ -84,9 +86,11 @@ def test_xgrids_compatibility_profile_keeps_evidence_levels_independent() -> Non
assert channels["spatial.point-cloud.live"]["evidence"] == verified_stream
assert channels["spatial.pose.live"]["evidence"] == verified_stream
assert channels["device.status.live"]["evidence"] == raw_status
assert channels["device.heartbeat.live"]["evidence"] == raw_status
assert channels["device.status.live"]["semantic_payload"] is None
assert channels["device.modeling.live"]["evidence"] == decoded_status
assert channels["device.status.live"]["evidence"] == decoded_status
assert channels["device.heartbeat.live"]["evidence"] == observed_raw
assert "ScanTime" in channels["device.modeling.live"]["semantic_payload"]
assert "modeling-state" in channels["device.status.live"]["semantic_payload"]
camera = channels["camera.preview.live"]
assert camera["discovery_status"] == "observed"
@@ -151,8 +155,21 @@ def test_xgrids_compatibility_profile_maps_actions_without_enabling_writes() ->
assert mapping["evidence_kind"] == "owner-controlled-wire-observation"
assert mapping["topic"] == "lixel/application/request/modeling"
assert mapping["qos"] == 2
assert mapping["retain"] is False
assert mapping["message_type"] == "ModelingRequest"
assert mapping["action_field_value"] == action_code
assert mapping["header_contract"]["session_id"] == "{device_id}:ModelingRequest"
assert mapping["success_result_code"] == 302_252_033
if action_id == "acquisition.start":
assert mapping["request_fields"] == {
"project_name": "required-operator-value",
"record_mode": 2,
"scan_mode": 1,
"mount_type": 0,
"pre_project_id": "omitted-in-retained-request",
}
else:
assert mapping["request_fields"] == {}
assert mapping["required_unresolved_context"]
assert mapping["evidence"]["observed"] is True
assert mapping["evidence"]["decoded"] is True
@@ -178,6 +195,45 @@ def test_xgrids_compatibility_profile_rejects_vendor_write_promotion() -> None:
LOADER.validate_compatibility_profile(modified)
def test_xgrids_compatibility_profile_rejects_noncanonical_modeling_header() -> None:
profile = LOADER.load_compatibility_profile()
modified = copy.deepcopy(profile)
actions = _by_id(modified["acquisition_control"]["semantic_actions"])
actions["acquisition.start"]["vendor_request_mapping"]["header_contract"]["session_id"] = (
"caller-provided"
)
with pytest.raises(LOADER.CompatibilityProfileError, match="header contract"):
LOADER.validate_compatibility_profile(modified)
def test_xgrids_compatibility_profile_pins_vendor_and_inert_request_mapping() -> None:
profile = LOADER.load_compatibility_profile()
wrong_model = copy.deepcopy(profile)
wrong_model["scope"]["vendor"] = "OTHER"
with pytest.raises(LOADER.CompatibilityProfileError, match="vendor/model"):
LOADER.validate_compatibility_profile(wrong_model)
wrong_message = copy.deepcopy(profile)
wrong_actions = _by_id(wrong_message["acquisition_control"]["semantic_actions"])
wrong_actions["acquisition.start"]["vendor_request_mapping"]["message_type"] = "OtherRequest"
with pytest.raises(LOADER.CompatibilityProfileError, match="message type"):
LOADER.validate_compatibility_profile(wrong_message)
missing_write_gate = copy.deepcopy(profile)
missing_actions = _by_id(missing_write_gate["acquisition_control"]["semantic_actions"])
del missing_actions["acquisition.stop"]["vendor_request_mapping"]["write_enabled"]
with pytest.raises(LOADER.CompatibilityProfileError, match="explicitly"):
LOADER.validate_compatibility_profile(missing_write_gate)
wrong_telemetry = copy.deepcopy(profile)
wrong_channels = _by_id(wrong_telemetry["channels"])
wrong_channels["device.modeling.live"]["bounds"]["max_mqtt_payload_bytes"] = 1
with pytest.raises(LOADER.CompatibilityProfileError, match="telemetry channel"):
LOADER.validate_compatibility_profile(wrong_telemetry)
def test_xgrids_compatibility_profile_rejects_claimed_camera_endpoint() -> None:
profile = LOADER.load_compatibility_profile()
modified = copy.deepcopy(profile)