feat(lab): publish E31 through E33 results
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { after, before, test } from "node:test";
|
||||
|
||||
import { createServer } from "vite";
|
||||
|
||||
let server;
|
||||
let fetchAdvancedLaboratoryResults;
|
||||
let AdvancedLaboratoryContractError;
|
||||
|
||||
const authority = {
|
||||
commands_enabled: false,
|
||||
navigation_or_safety_accepted: false,
|
||||
};
|
||||
|
||||
function catalog(item) {
|
||||
return {
|
||||
schema_version: "missioncore.laboratory-advanced-catalog/v1",
|
||||
configured: true,
|
||||
items: [item],
|
||||
candidate_total: 1,
|
||||
invalid_total: 0,
|
||||
access: "read-only",
|
||||
};
|
||||
}
|
||||
|
||||
function e31() {
|
||||
return {
|
||||
result_id: `e31-source-qualification-${"1".repeat(64)}`,
|
||||
created_at_utc: "2026-07-27T10:00:00Z",
|
||||
source_session_id: "20260720T065719Z_viewer_live",
|
||||
status: "accepted-diagnostic-source-profile",
|
||||
eligible_for_e32: true,
|
||||
profile_id: "e31-ravnoves00-source-qualification/v1",
|
||||
producer_sha256: "a".repeat(64),
|
||||
metrics: {
|
||||
frame_count: 4489,
|
||||
available_binding_count: 3928,
|
||||
available_fraction: 0.875,
|
||||
lidar_camera_p95_ms: 70.78,
|
||||
pose_point_p95_ms: 21.85,
|
||||
selected_offset_ms: 0,
|
||||
correspondence_count: 87,
|
||||
supported_fraction: 1,
|
||||
semantic_self_sample_count: 8,
|
||||
semantic_self_collateral_count: 0,
|
||||
exact_geometry_correction_count: 2,
|
||||
geometry_point_mask_status: "rejected",
|
||||
},
|
||||
limitations: ["source scoped"],
|
||||
authority,
|
||||
access: "read-only",
|
||||
};
|
||||
}
|
||||
|
||||
function e32() {
|
||||
return {
|
||||
result_id: `e32-track-geometry-${"2".repeat(64)}`,
|
||||
created_at_utc: "2026-07-27T10:10:00Z",
|
||||
source_session_id: "20260720T065719Z_viewer_live",
|
||||
status: "accepted-diagnostic-track-geometry-replay",
|
||||
profile_id: "e32-exact-e29-to-track-geometry/v1",
|
||||
producer_sha256: "b".repeat(64),
|
||||
e31_result_id: e31().result_id,
|
||||
metrics: {
|
||||
frames_total: 4489,
|
||||
frames_source_available: 3928,
|
||||
semantic_published: 20119,
|
||||
semantic_masked: 385,
|
||||
geometry_published: 21318,
|
||||
observations_arbitrated: 709,
|
||||
overlapping_claims_removed: 4461,
|
||||
qualified_points_published: 2119302,
|
||||
qualified_points_withheld: 1558,
|
||||
frame_processing_p95_ms: 3.081,
|
||||
build_elapsed_ms: 10194.25,
|
||||
},
|
||||
authority,
|
||||
access: "read-only",
|
||||
};
|
||||
}
|
||||
|
||||
function e33() {
|
||||
return {
|
||||
result_id: `e33-worker-shadow-${"3".repeat(64)}`,
|
||||
created_at_utc: "2026-07-27T10:36:13Z",
|
||||
source_session_id: "20260720T065719Z_viewer_live",
|
||||
status: "accepted-recorded-source-paced-shadow",
|
||||
e32_result_id: e32().result_id,
|
||||
pipeline_id: "e32-track-geometry-recorded-source-paced-worker-shadow/v1",
|
||||
mode: "full-session-qualification",
|
||||
worker: {
|
||||
node: "DESKTOP-OPJ8J04",
|
||||
container_image: "qualified@sha256:abc",
|
||||
python: "3.12.3",
|
||||
numpy: "1.26.4",
|
||||
},
|
||||
metrics: {
|
||||
source_frames: 4489,
|
||||
delivered_frames: 4489,
|
||||
input_superseded: 0,
|
||||
result_superseded: 0,
|
||||
effective_delivery_fps: 10.006,
|
||||
deadline_miss_fraction: 0,
|
||||
processing_p95_ms: 0.749,
|
||||
release_lag_p95_ms: 0.461,
|
||||
result_age_p95_ms: 2.668,
|
||||
process_rss_p95_mib: 90.32,
|
||||
gpu_utilization_p95_percent: 52,
|
||||
gpu_visible: true,
|
||||
work_queue_capacity: 2,
|
||||
result_queue_capacity: 2,
|
||||
wall_to_ideal_ratio: 1.0001,
|
||||
},
|
||||
authority,
|
||||
access: "read-only",
|
||||
};
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
server = await createServer({
|
||||
appType: "custom",
|
||||
logLevel: "silent",
|
||||
server: { middlewareMode: true },
|
||||
});
|
||||
({
|
||||
fetchAdvancedLaboratoryResults,
|
||||
AdvancedLaboratoryContractError,
|
||||
} = await server.ssrLoadModule("/src/core/laboratory/advancedResults.ts"));
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await server?.close();
|
||||
});
|
||||
|
||||
test("decodes E31, E32 and E33 from separate read-only catalogs", async () => {
|
||||
const requests = [];
|
||||
const items = [e31(), e32(), e33()];
|
||||
const decoded = await fetchAdvancedLaboratoryResults({
|
||||
fetcher: async (input, init) => {
|
||||
requests.push({ input: String(input), method: init?.method });
|
||||
return new Response(JSON.stringify(catalog(items[requests.length - 1])), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
},
|
||||
});
|
||||
assert.equal(decoded.e31.metrics.availableBindingCount, 3928);
|
||||
assert.equal(decoded.e32.metrics.qualifiedPointsPublished, 2119302);
|
||||
assert.equal(decoded.e33.metrics.deliveredFrames, 4489);
|
||||
assert.deepEqual(requests, [
|
||||
{ input: "/api/v1/laboratory/e31/results?limit=1", method: "GET" },
|
||||
{ input: "/api/v1/laboratory/e32/results?limit=1", method: "GET" },
|
||||
{ input: "/api/v1/laboratory/e33/results?limit=1", method: "GET" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("rejects authority escalation in an accepted-looking result", async () => {
|
||||
const forged = {
|
||||
...e31(),
|
||||
authority: { ...authority, commands_enabled: true },
|
||||
};
|
||||
await assert.rejects(
|
||||
() => fetchAdvancedLaboratoryResults({
|
||||
fetcher: async (input) => new Response(JSON.stringify(catalog(
|
||||
String(input).includes("/e31/") ? forged
|
||||
: String(input).includes("/e32/") ? e32() : e33(),
|
||||
)), { status: 200 }),
|
||||
}),
|
||||
AdvancedLaboratoryContractError,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user