Files
NODEDC_MISSION_CORE/apps/control-station/test/m47ReferenceGraph.test.mjs
T

282 lines
9.3 KiB
JavaScript

import assert from "node:assert/strict";
import { after, before, test } from "node:test";
import { createServer } from "vite";
let server;
let fetchM47ReferenceGraphLab;
const resultId = `m47-reference-graph-lab-${"a".repeat(64)}`;
const graphResultId = `m47-reference-graph-${"b".repeat(64)}`;
const visualResultId = `m4-threat-replay-${"c".repeat(64)}`;
const semanticResultId = `e47-semantic-slam-${"d".repeat(64)}`;
before(async () => {
server = await createServer({
appType: "custom",
logLevel: "silent",
server: { middlewareMode: true },
});
({ fetchM47ReferenceGraphLab } = await server.ssrLoadModule(
"/src/core/laboratory/m47ReferenceGraph.ts",
));
});
after(async () => {
await server?.close();
});
function m4Result() {
return {
schema_version: "missioncore.m4-threat-replay-view/v1",
result_id: visualResultId,
created_at_utc: "2026-08-05T15:36:01.553Z",
status: "accepted",
profile_id: "m4-ravnoves00-virtual-corridor/v3",
rig_profile_id: "virtual-base-footprint-1000x600/v3",
corridor_profile_id: "ravnoves00-forward-corridor-8m/v3",
source_result_ids: {
detector: `m4-detector-replay-${"d".repeat(64)}`,
geometry: `m4-geometry-replay-${"e".repeat(64)}`,
temporal: `m4-temporal-replay-${"f".repeat(64)}`,
},
metrics: {
decisions: { threat: 7606, "not-threat": 10769, unknown: 128878 },
evidence: {
"camera-only": 10158,
"current-metric": 28081,
"rolling-map-retained": 70989,
"stale-or-held": 38025,
},
fixtures: { critical: 5, critical_false_not_threat: 0, passed: 10, total: 10 },
runtime: {
frames_per_second: 175.0,
provider_latency_p50_ms: 2.5,
provider_latency_p95_ms: 7.2,
provider_latency_max_ms: 26.6,
},
body_frame: {
available: 3928,
qualified: 3861,
rejected: 67,
camera_forward_alignment_deg: { p95: 8.439, maximum: 24.252 },
},
reason_counts: { "geometry-only-evidence": 87550 },
},
configuration: {
virtual_body_m: [1, 0.6],
nominal_sensor_height_m: 1.25,
forward_corridor_m: 8,
prediction_horizon_seconds: 5,
body_frame: {
origin: "local-surface-vertical-projection",
up: "vendor-slam-map-gravity-axis",
forward: "smoothed-slam-trajectory-validated-by-camera-axis",
},
},
limitations: ["replay only"],
accepted: true,
authority: "replay-simulated",
physical_collision_accepted: false,
actuation_allowed: false,
};
}
function semanticResult() {
return {
schema_version: "missioncore.e47-semantic-slam-view/v1",
result_id: semanticResultId,
created_at_utc: "2026-08-06T08:13:48.601Z",
status: "diagnostic-semantic-slam-shadow",
profile_id: "ravnoves00-eomt-kb4-slam-shadow/v1",
base_m4_result_id: visualResultId,
semantic_result_id: `result-${"e".repeat(64)}`,
geometry_result_id: `m4-geometry-replay-${"f".repeat(64)}`,
source_pack_id: `e10-lidar-pack-${"1".repeat(64)}`,
calibration_content_sha256: "2".repeat(64),
provider: {
provider_id: "eomt-cityscapes-semantic-control/v1",
model_id: "cityscapes-semantic-eomt",
model_revision: "3".repeat(40),
model_weights_sha256: "4".repeat(64),
preprocess_id: "raw-kb4-valid-fov-semantic/v1",
},
temporal_binding: {
semantic_to_camera: "exact-sequence-and-session-time",
camera_to_lidar: "accepted-e6-nearest-host-arrival-best-effort",
clock_basis: "recorded-host-monotonic-arrival",
maximum_lidar_camera_delta_ms: 100,
maximum_pose_point_delta_ms: 100,
physical_synchronization_proven: false,
},
taxonomy: [{
class_id: 1,
label: "road",
disposition: "labeled",
color_rgb: [128, 64, 128],
}],
metrics: {
frames: { total: 4489, mask_available: 4489, source_available: 3928 },
points: { total: 1, projected: 1, labeled: 1, ambiguous: 0, unprojected: 0, absent: 0 },
observations: { total: 1, labeled: 1, ambiguous: 0, unprojected: 0, absent: 0 },
runtime: { elapsed_ms: 1000, frames_per_second: 4.489 },
},
acceptance: {
artifact_contract_passed: true,
frame_accounting_passed: true,
point_accounting_passed: true,
observation_binding_passed: true,
temporal_binding_passed: true,
independent_semantic_truth_passed: false,
provider_promoted: false,
},
limitations: ["diagnostic only"],
ground_truth: false,
semantic_authority: "diagnostic-only",
navigation_or_safety_accepted: false,
actuation_allowed: false,
};
}
function evidenceReport() {
const mismatch = {
source_binding: 0,
current: 0,
rolling_retained: 0,
held: 0,
expired: 0,
camera_uncertainty: 0,
threat_assessments: 0,
};
const raw = {
schema_version: "missioncore.reference-perception-graph-lab-report/v2",
result_id: resultId,
source: { graph_result_id: graphResultId },
method: { graph_id: "reference-perception-graph/v2" },
execution: {
worker_id: "worker-006",
worker_node: "DESKTOP-OPJ8J04",
artifact_sha256: "1".repeat(64),
code_revision: "2".repeat(40),
elapsed_seconds: 198.126,
},
metrics: {
frames: { expected: 4489, admitted: 4489, delivered: 4489 },
parity_mismatch_counts: mismatch,
queue_high_watermarks: {
detector: 2,
geometry: 2,
temporal: 2,
rolling: 2,
threat: 2,
},
},
acceptance: { accepted: true },
authority: {
commands_enabled: false,
actuation_allowed: false,
navigation_or_safety_accepted: false,
},
visual_evidence: {
linked_result_id: visualResultId,
semantic_result_id: semanticResultId,
shared_recorded_clock: true,
video_camera_3d_plan_available: true,
camera_semantic_overlay_available: true,
semantic_binding: "exact-sequence-and-session-time",
},
limitations: ["recorded replay only"],
};
return {
schema_version: "missioncore.laboratory-evidence-report/v1",
work_id: "m47-reference-graph-shadow",
result_id: resultId,
created_at_utc: "2026-08-23T18:00:16.061Z",
access: "read-only",
proof: {
document_schema_version: "missioncore.reference-perception-graph-lab/v2",
document_sha256: "3".repeat(64),
identity_sha256: "a".repeat(64),
report_schema_version: raw.schema_version,
report_sha256: "4".repeat(64),
artifact_count: 9,
verified_artifact_count: 9,
},
completeness: { identity: "recorded" },
identity: { authority: raw.authority },
source: raw.source,
configuration: null,
method: raw.method,
execution: raw.execution,
resources: null,
metrics: raw.metrics,
gates: raw.acceptance,
decision: null,
limitations: raw.limitations,
authority: raw.authority,
artifacts: [],
visual_evidence: {},
raw_report: raw,
};
}
test("M4.7 binds exact Worker graph proof to the synchronized M4.6 visual", async () => {
const requests = [];
const result = await fetchM47ReferenceGraphLab({
resultId,
fetcher: async (input) => {
const path = String(input);
requests.push(path);
const payload = path.includes("/evidence-reports/")
? evidenceReport()
: path.includes("/e47-semantic-slam/") ? semanticResult() : m4Result();
return new Response(JSON.stringify(payload), { status: 200 });
},
});
assert.equal(result.graphResultId, graphResultId);
assert.equal(result.visual.resultId, visualResultId);
assert.equal(result.semantic.resultId, semanticResultId);
assert.equal(result.worker.id, "worker-006");
assert.equal(result.frames.delivered, 4489);
assert.deepEqual(Object.values(result.parityMismatchCounts), Array(7).fill(0));
assert.equal(Math.max(...Object.values(result.queueHighWatermarks)), 2);
assert.deepEqual(requests, [
`/api/v1/laboratory/evidence-reports/m47-reference-graph-shadow/${resultId}`,
`/api/v1/laboratory/m4-threat/results/${visualResultId}`,
`/api/v1/laboratory/e47-semantic-slam/results/${semanticResultId}`,
]);
});
test("M4.7 keeps exact visual binding during a rolling API deployment", async () => {
const requests = [];
const result = await fetchM47ReferenceGraphLab({
resultId,
fetcher: async (input) => {
const path = String(input);
requests.push(path);
if (path.includes("/evidence-reports/")) {
return new Response(JSON.stringify(evidenceReport()), { status: 200 });
}
if (path.endsWith(`/${visualResultId}`)) {
return new Response(null, { status: 404 });
}
if (path.includes("/e47-semantic-slam/")) {
return new Response(JSON.stringify(semanticResult()), { status: 200 });
}
return new Response(JSON.stringify({
schema_version: "missioncore.m4-threat-replay-catalog/v1",
items: [m4Result()],
}), { status: 200 });
},
});
assert.equal(result.visual.resultId, visualResultId);
assert.deepEqual(requests, [
`/api/v1/laboratory/evidence-reports/m47-reference-graph-shadow/${resultId}`,
`/api/v1/laboratory/m4-threat/results/${visualResultId}`,
"/api/v1/laboratory/m4-threat/results?limit=10",
`/api/v1/laboratory/e47-semantic-slam/results/${semanticResultId}`,
]);
});