feat(simulation): add provider-neutral worker profile

This commit is contained in:
DCCONSTRUCTIONS
2026-07-25 00:29:00 +03:00
parent 5abd07d2bf
commit 37c24b5fa8
21 changed files with 1275 additions and 121 deletions
+15 -9
View File
@@ -18,6 +18,7 @@ from k1link.simulation import (
RunKind,
RunState,
)
from k1link.simulation.stock_rover import STOCK_ROVER_PROVIDER_PROFILE
from k1link.web.polygon_api import (
AckermannCommandRequest,
StartStockRoverRequest,
@@ -256,7 +257,7 @@ class _FakeWorkerGateway:
self.calls.append(("command", idempotency_key))
assert run_id == self.active_run_id
return {
"schema_version": "missioncore.command-acceptance/v1",
"schema_version": "missioncore.command-acceptance/v2",
"run_id": run_id,
"command_id": "cmd-test",
"sequence": 1,
@@ -266,17 +267,18 @@ class _FakeWorkerGateway:
"steering_normalized": steering_normalized,
"authority_scope": "virtual-only",
"delivery": {
"provider": "px4-ros2-offboard",
"mode": "speed-steering",
"armed": True,
"offboard": True,
"provider_id": "px4-ros2-offboard",
"control_profile": "rover-speed-steering/v1",
"accepted": True,
"controller_ready": True,
"ttl_expired_count": 0,
"diagnostics": {"armed": True, "offboard": True},
},
}
def _status(self) -> dict[str, Any]:
return {
"schema_version": "missioncore.simulation-worker-status/v1",
"schema_version": "missioncore.simulation-worker-status/v2",
"worker_id": "mission-gpu-s1",
"transport": "unix",
"mode": "simulation",
@@ -284,7 +286,10 @@ class _FakeWorkerGateway:
"control_available": True,
"active_run_id": self.active_run_id,
"run_state": "running" if self.active_run_id else None,
"provider_ids": ["px4-gazebo-stock-rover"] if self.active_run_id else [],
"active_provider_ids": (
["px4-gazebo-stock-rover"] if self.active_run_id else []
),
"provider_profile": STOCK_ROVER_PROVIDER_PROFILE.to_dict(),
"isolation": {
"network": "loopback-only-netns",
"process_identity": "missioncore",
@@ -340,7 +345,7 @@ def test_polygon_worker_api_fails_closed_then_proxies_virtual_only_lifecycle() -
idempotency_key="command-001",
)
assert command["authority_scope"] == "virtual-only"
assert command["delivery"]["offboard"] is True
assert command["delivery"]["controller_ready"] is True
stopped = _endpoint(enabled, "/api/v1/polygon/worker/runs/{run_id}/stop", "POST")(
run_id=running["active_run_id"],
idempotency_key="stop-001",
@@ -366,7 +371,8 @@ def test_polygon_worker_status_is_explicitly_unavailable_when_not_registered() -
worker_provider=lambda: None,
)
status = _endpoint(router, "/api/v1/polygon/worker", "GET")()
assert status["schema_version"] == "missioncore.simulation-worker-status/v1"
assert status["schema_version"] == "missioncore.simulation-worker-status/v2"
assert status["available"] is False
assert status["control_available"] is False
assert status["provider_profile"] is None
assert status["authority"]["scope"] == "virtual-only"