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
@@ -175,7 +175,7 @@ function jsonResponse(payload, status = 200) {
function workerStatus(overrides = {}) {
return {
schema_version: "missioncore.simulation-worker-status/v1",
schema_version: "missioncore.simulation-worker-status/v2",
worker_id: "mission-gpu-s1",
transport: "unix",
mode: "simulation",
@@ -183,7 +183,44 @@ function workerStatus(overrides = {}) {
control_available: true,
active_run_id: "s1c-6cb1495-20260724t180000z-aabbcc",
run_state: "running",
provider_ids: ["micro-xrce-dds-agent", "px4-gazebo-stock-rover"],
active_provider_ids: ["micro-xrce-dds-agent", "px4-gazebo-stock-rover"],
provider_profile: {
schema_version: "missioncore.simulation-provider-profile/v1",
profile_id: "stock-rover-gazebo-px4-s1d",
providers: [
{
provider_id: "gazebo",
roles: ["world", "physics", "state", "sensor"],
capabilities: [
"clock.simulation",
"state.vehicle-pose",
"truth.ground-truth",
"sensor.virtual",
],
},
{
provider_id: "px4-ros2-offboard",
roles: ["controller"],
capabilities: ["command.rover-speed-steering/v1"],
},
{
provider_id: "micro-xrce-dds-agent",
roles: ["transport"],
capabilities: ["transport.ros2"],
},
],
clock: {
provider_id: "gazebo",
domain: "gazebo:/clock",
unit: "nanoseconds",
mode: "simulation",
},
control_profiles: ["rover-speed-steering/v1"],
canonical_frames: {
world: "map_enu",
body: "base_link_flu",
},
},
isolation: {
network: "loopback-only-netns",
process_identity: "missioncore",
@@ -229,7 +266,7 @@ function vehicleState(overrides = {}) {
function commandAcceptance(overrides = {}) {
return {
schema_version: "missioncore.command-acceptance/v1",
schema_version: "missioncore.command-acceptance/v2",
run_id: "s1c-6cb1495-20260724t180000z-aabbcc",
command_id: "cmd-aabbcc",
sequence: 1,
@@ -239,11 +276,15 @@ function commandAcceptance(overrides = {}) {
steering_normalized: -0.55,
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,
},
},
...overrides,
};
@@ -353,7 +394,8 @@ test("Polygon Live decodes only D-only virtual diagnostic state", () => {
assert.equal(status.activeRunId, live.runId);
assert.equal(status.isolation.artifactPolicy, "d-only");
assert.deepEqual(live.position, { x: 1.25, y: -0.5, z: 0.18 });
assert.equal(command.offboard, true);
assert.equal(command.controllerReady, true);
assert.equal(command.deliveryProvider, "px4-ros2-offboard");
assert.equal(command.steeringNormalized, -0.55);
assert.throws(
() => decodePolygonWorkerStatus(workerStatus({
@@ -381,12 +423,67 @@ test("Polygon Live decodes only D-only virtual diagnostic state", () => {
);
});
test("Polygon Live accepts an Unreal provider behind the canonical contract", () => {
const unrealStatus = workerStatus({
provider_profile: {
...workerStatus().provider_profile,
profile_id: "unreal-native-rover-v1",
providers: [
{
provider_id: "unreal-native",
roles: ["world", "physics", "state", "sensor"],
capabilities: [
"clock.simulation",
"state.vehicle-pose",
"truth.ground-truth",
"sensor.virtual",
],
},
{
provider_id: "unreal-direct-control",
roles: ["controller"],
capabilities: ["command.rover-speed-steering/v1"],
},
],
clock: {
provider_id: "unreal-native",
domain: "unreal:fixed-step",
unit: "nanoseconds",
mode: "simulation",
},
},
});
const status = decodePolygonWorkerStatus(unrealStatus);
const live = decodePolygonVehicleState(vehicleState({
source: {
provider: "unreal-native",
topic: "missioncore/vehicle-state",
signal: "ground-truth",
quality: "diagnostic",
},
}));
const command = decodePolygonCommandAcceptance(commandAcceptance({
delivery: {
provider_id: "unreal-direct-control",
control_profile: "rover-speed-steering/v1",
accepted: true,
controller_ready: true,
ttl_expired_count: 0,
diagnostics: { fixed_step: true },
},
}));
assert.equal(status.providerProfile.clock.domain, "unreal:fixed-step");
assert.equal(live.sourceProvider, "unreal-native");
assert.equal(command.deliveryProvider, "unreal-direct-control");
});
test("Polygon Live uses same-origin gateway and idempotent lifecycle requests", async () => {
const calls = [];
const stopped = workerStatus({
active_run_id: null,
run_state: null,
provider_ids: [],
active_provider_ids: [],
});
const fetcher = async (url, init) => {
calls.push({ url: String(url), init });