feat(k1): complete primary acquisition lifecycle
This commit is contained in:
@@ -62,12 +62,15 @@ def _validate_evidence(value: Any, path: str) -> dict[str, bool]:
|
||||
if set(evidence) != set(EVIDENCE_FLAGS):
|
||||
expected = ", ".join(EVIDENCE_FLAGS)
|
||||
raise CompatibilityProfileError(f"{path} must contain exactly: {expected}")
|
||||
validated: dict[str, bool] = {}
|
||||
for flag in EVIDENCE_FLAGS:
|
||||
if not isinstance(evidence[flag], bool):
|
||||
flag_value = evidence[flag]
|
||||
if not isinstance(flag_value, bool):
|
||||
raise CompatibilityProfileError(f"{path}.{flag} must be a boolean")
|
||||
validated[flag] = flag_value
|
||||
if evidence["write_enabled"]:
|
||||
raise CompatibilityProfileError(f"{path}.write_enabled must remain false in v1")
|
||||
return evidence # type: ignore[return-value]
|
||||
return validated
|
||||
|
||||
|
||||
def _walk_and_validate_evidence(value: Any, path: str = "$") -> None:
|
||||
@@ -240,6 +243,7 @@ def _validate_channels(profile: dict[str, Any]) -> None:
|
||||
expected_ids = {
|
||||
"spatial.point-cloud.live",
|
||||
"spatial.pose.live",
|
||||
"device.modeling.live",
|
||||
"device.status.live",
|
||||
"device.heartbeat.live",
|
||||
"camera.preview.live",
|
||||
@@ -271,21 +275,66 @@ def _validate_channels(profile: dict[str, Any]) -> None:
|
||||
physical_verified=True,
|
||||
)
|
||||
|
||||
for channel_id, topic in (
|
||||
("device.status.live", "lixel/application/report/device_status"),
|
||||
("device.heartbeat.live", "lixel/application/report/heartbeat"),
|
||||
):
|
||||
channel = channels[channel_id]
|
||||
if channel.get("topic") != topic or channel.get("semantic_payload") is not None:
|
||||
raise CompatibilityProfileError(f"{channel_id} must remain raw-only in v1")
|
||||
_expect_evidence(
|
||||
channel,
|
||||
f"$.channels[{channel_id}]",
|
||||
observed=True,
|
||||
decoded=False,
|
||||
replay_verified=False,
|
||||
physical_verified=True,
|
||||
modeling = channels["device.modeling.live"]
|
||||
if (
|
||||
modeling.get("topic") != "lixel/application/report/modeling"
|
||||
or modeling.get("wire_format") != "protobuf ModelingReport acquisition telemetry subset"
|
||||
or modeling.get("semantic_payload")
|
||||
!= (
|
||||
"nonnegative MoveDistance metres, MoveSpeed metres per second, "
|
||||
"int64 ScanTime at two ticks per second, and int32 PgoProgress"
|
||||
)
|
||||
or modeling.get("bounds")
|
||||
!= {
|
||||
"max_mqtt_payload_bytes": 65_536,
|
||||
"max_fields": 64,
|
||||
"max_nested_fields": 16,
|
||||
}
|
||||
):
|
||||
raise CompatibilityProfileError("modeling telemetry channel differs from evidence")
|
||||
_expect_evidence(
|
||||
modeling,
|
||||
"$.channels[device.modeling.live]",
|
||||
observed=True,
|
||||
decoded=True,
|
||||
replay_verified=False,
|
||||
physical_verified=True,
|
||||
)
|
||||
|
||||
status = channels["device.status.live"]
|
||||
if (
|
||||
status.get("topic") != "lixel/application/report/device_status"
|
||||
or status.get("wire_format") != "protobuf DeviceStatusReport acquisition lifecycle subset"
|
||||
or status.get("semantic_payload")
|
||||
!= (
|
||||
"bounded modeling-state base-offset mapping, init-ready flag, "
|
||||
"project presence and redacted identity fields"
|
||||
)
|
||||
):
|
||||
raise CompatibilityProfileError("device-status channel differs from evidence")
|
||||
_expect_evidence(
|
||||
status,
|
||||
"$.channels[device.status.live]",
|
||||
observed=True,
|
||||
decoded=True,
|
||||
replay_verified=False,
|
||||
physical_verified=True,
|
||||
)
|
||||
|
||||
heartbeat = channels["device.heartbeat.live"]
|
||||
if (
|
||||
heartbeat.get("topic") != "lixel/application/report/heartbeat"
|
||||
or heartbeat.get("semantic_payload") is not None
|
||||
):
|
||||
raise CompatibilityProfileError("device.heartbeat.live must remain raw-only in v1")
|
||||
_expect_evidence(
|
||||
heartbeat,
|
||||
"$.channels[device.heartbeat.live]",
|
||||
observed=True,
|
||||
decoded=False,
|
||||
replay_verified=False,
|
||||
physical_verified=True,
|
||||
)
|
||||
|
||||
camera = channels["camera.preview.live"]
|
||||
if camera.get("discovery_status") != "observed":
|
||||
@@ -353,14 +402,53 @@ def _validate_acquisition_control(profile: dict[str, Any]) -> None:
|
||||
)
|
||||
if mapping.get("evidence_kind") != "owner-controlled-wire-observation":
|
||||
raise CompatibilityProfileError(f"{action_id} vendor mapping differs from evidence")
|
||||
if mapping.get("transport") != "MQTT 3.1.1":
|
||||
raise CompatibilityProfileError(f"{action_id} transport differs from evidence")
|
||||
if mapping.get("message_type") != "ModelingRequest":
|
||||
raise CompatibilityProfileError(f"{action_id} message type differs from evidence")
|
||||
if mapping.get("write_enabled") is not False:
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} vendor mapping must explicitly remain write-disabled"
|
||||
)
|
||||
if mapping.get("topic") != "lixel/application/request/modeling":
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} vendor topic differs from static evidence"
|
||||
)
|
||||
if mapping.get("qos") != 2 or mapping.get("action_field_value") != action_value:
|
||||
if (
|
||||
mapping.get("qos") != 2
|
||||
or mapping.get("retain") is not False
|
||||
or mapping.get("action_field_value") != action_value
|
||||
):
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} vendor mapping differs from static evidence"
|
||||
)
|
||||
if mapping.get("header_contract") != {
|
||||
"device_id": "explicit-observed-identity",
|
||||
"session_id": "{device_id}:ModelingRequest",
|
||||
"openapi_key": "explicit-observed-value-with-unresolved-provenance",
|
||||
}:
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} header contract differs from retained evidence"
|
||||
)
|
||||
expected_request_fields: dict[str, object] = (
|
||||
{
|
||||
"project_name": "required-operator-value",
|
||||
"record_mode": 2,
|
||||
"scan_mode": 1,
|
||||
"mount_type": 0,
|
||||
"pre_project_id": "omitted-in-retained-request",
|
||||
}
|
||||
if action_id == "acquisition.start"
|
||||
else {}
|
||||
)
|
||||
if mapping.get("request_fields") != expected_request_fields:
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} request fields differ from retained evidence"
|
||||
)
|
||||
if mapping.get("success_result_code") != 302_252_033:
|
||||
raise CompatibilityProfileError(
|
||||
f"{action_id} success result differs from retained evidence"
|
||||
)
|
||||
if not _array(
|
||||
mapping.get("required_unresolved_context"),
|
||||
f"$.acquisition_control.semantic_actions[{action_id}].required_unresolved_context",
|
||||
@@ -407,6 +495,8 @@ def validate_compatibility_profile(profile: Any) -> dict[str, Any]:
|
||||
raise CompatibilityProfileError("unexpected compatibility profile_id")
|
||||
|
||||
scope = _object(root.get("scope"), "$.scope")
|
||||
if scope.get("vendor") != "XGRIDS" or scope.get("model") != "LixelKity K1":
|
||||
raise CompatibilityProfileError("profile vendor/model must remain XGRIDS LixelKity K1")
|
||||
firmware = _object(scope.get("firmware"), "$.scope.firmware")
|
||||
if firmware != {"match": "exact", "version": "3.0.2"}:
|
||||
raise CompatibilityProfileError("profile must match firmware 3.0.2 exactly")
|
||||
@@ -470,7 +560,8 @@ def matches_target(
|
||||
"""Return whether an already validated exact-match profile covers the target."""
|
||||
validated = validate_compatibility_profile(profile)
|
||||
scope = validated["scope"]
|
||||
return scope["firmware"]["version"] == firmware and scope["topology"] == topology
|
||||
firmware_scope = _object(scope.get("firmware"), "$.scope.firmware")
|
||||
return firmware_scope.get("version") == firmware and scope.get("topology") == topology
|
||||
|
||||
|
||||
def _main() -> int:
|
||||
|
||||
Reference in New Issue
Block a user