Add D455 sensor host and shared Node/Core preparation surface

This commit is contained in:
DCCONSTRUCTIONS
2026-09-05 22:27:07 +03:00
parent 3616acc648
commit b1aaa40508
41 changed files with 2293 additions and 19 deletions
+87
View File
@@ -299,3 +299,90 @@ def test_bootstrap_pin_is_verified_before_secret_is_sent(setup, monkeypatch, wro
"ok": True
}
assert len(sent) == 1
def sensor_inventory(row):
now = datetime.now(UTC).isoformat()
item = {
"id": "rsd455_01234567890123456789012345678901",
"name": "Test camera",
"snapshot": {
"context": {
"session_id": "sensor_test",
"device": {
"device_id": "rsd455_01234567890123456789012345678901",
"model": {
"plugin_id": "missioncore.realsense",
"plugin_version": "0.6.0",
"model_id": "realsense.d455",
},
"stability": "stable",
"basis": "hardware-identifier",
},
"execution": {
"node_id": row["node_id"],
"agent_instance_id": "driver_test",
"platform": "linux",
},
"opened_at": now,
},
"revision": 0,
"enrollment": "empty",
"connectivity": "connected",
"acquisition": "idle",
"observed_at": now,
},
}
value = heartbeat(row)
value["devices"] = [item]
value["sensor_state"] = {"items": [item], "operations": [], "preparation": None}
return value
def test_sensor_commands_require_pairing_and_keep_uncertain_outcome(setup):
from k1link.fleet import sensors
fleet, _, _, _ = setup
public, _ = create(setup)
row = setup[0].find(public["id"])
inventory = sensor_inventory(row)
fleet.receive(cert(row), "/v1/node/heartbeat", inventory)
now = datetime.now(UTC)
command = {
"api_version": "missioncore.nodedc/plugin-sdk/v0alpha2",
"kind": "OperationRequest",
"operation_id": "op_01234567890123456789012345678901",
"idempotency_key": "op_01234567890123456789012345678901",
"session": {"device_id": inventory["devices"][0]["id"], "session_id": "sensor_test"},
"requested_at": now.isoformat(),
"deadline_at": (now + timedelta(seconds=60)).isoformat(),
"action_id": "start",
"parameters": {"record": True},
}
first = sensors.submit(fleet, row["id"], command)
assert first["state"] == "queued"
assert sensors.submit(fleet, row["id"], command) == first
with pytest.raises(PairingError):
sensors.submit(fleet, row["id"], {**command, "action_id": "stop"})
_, response = fleet.receive(cert(row), "/v1/node/heartbeat", inventory)
assert response["sensor_commands"] == [command]
inventory["sensor_results"] = [
{"command": command, "state": "unknown", "error": "test uncertainty"}
]
_, response = fleet.receive(cert(row), "/v1/node/heartbeat", inventory)
assert response["sensor_commands"] == []
assert sensors.operation(fleet, row["id"], command["operation_id"])["state"] == "unknown"
fleet.revoke(row["id"])
with pytest.raises(PairingError):
sensors.submit(fleet, row["id"], command)
def test_sensor_cannot_claim_another_board_identity(setup):
from k1link.fleet.sensors import validate_inventory
public, _ = create(setup)
row = setup[0].find(public["id"])
value = sensor_inventory(row)
value["devices"][0]["snapshot"]["context"]["execution"]["node_id"] = "node_wrong"
with pytest.raises(ValueError):
validate_inventory(value, row["node_id"])