fix(lab): restore semantic overlay in M4.7

This commit is contained in:
DCCONSTRUCTIONS
2026-08-23 22:40:07 +03:00
parent 34ed8a0f5f
commit a55ef475d9
11 changed files with 289 additions and 32 deletions
@@ -360,27 +360,65 @@ function parseResult(value: unknown): E47SemanticSlamResult {
}
export async function fetchE47SemanticSlamResult({
resultId: requestedResultId,
fetcher = fetch,
signal,
}: {
resultId?: string;
fetcher?: LaboratoryFetch;
signal?: AbortSignal;
} = {}): Promise<E47SemanticSlamResult | null> {
const response = await fetcher("/api/v1/laboratory/e47-semantic-slam/results?limit=1", {
headers: { Accept: "application/json" },
signal,
});
if (requestedResultId !== undefined) resultId(requestedResultId);
let response = await fetcher(
requestedResultId === undefined
? "/api/v1/laboratory/e47-semantic-slam/results?limit=1"
: `/api/v1/laboratory/e47-semantic-slam/results/${requestedResultId}`,
{ headers: { Accept: "application/json" }, signal },
);
let catalogFallback = false;
if (requestedResultId !== undefined && response.status === 404) {
response = await fetcher("/api/v1/laboratory/e47-semantic-slam/results?limit=10", {
headers: { Accept: "application/json" },
signal,
});
catalogFallback = true;
}
if (!response.ok) {
throw new E47SemanticSlamContractError(`E47 LAB недоступен: HTTP ${response.status}.`);
}
const payload = object(await response.json(), "E47 catalog");
exact(
payload.schema_version,
"missioncore.e47-semantic-slam-catalog/v1",
"E47 catalog schema",
);
const items = array(payload.items, "E47 catalog items");
return items.length ? parseResult(items[0]) : null;
const payload = await response.json();
if (requestedResultId === undefined || catalogFallback) {
const catalog = object(payload, "E47 catalog");
exact(
catalog.schema_version,
"missioncore.e47-semantic-slam-catalog/v1",
"E47 catalog schema",
);
const items = array(catalog.items, "E47 catalog items");
if (!items.length) return null;
const selected = requestedResultId === undefined
? items[0]
: items.find((candidate) => (
typeof candidate === "object"
&& candidate !== null
&& (candidate as Record<string, unknown>).result_id === requestedResultId
));
if (selected === undefined) {
throw new E47SemanticSlamContractError(
"E47 requested result: точный semantic-result отсутствует в каталоге.",
);
}
const parsed = parseResult(selected);
if (requestedResultId !== undefined && parsed.resultId !== requestedResultId) {
throw new E47SemanticSlamContractError("E47 requested result: нарушена идентичность.");
}
return parsed;
}
const parsed = parseResult(payload);
if (parsed.resultId !== requestedResultId) {
throw new E47SemanticSlamContractError("E47 requested result: нарушена идентичность.");
}
return parsed;
}
function parseFrame(
@@ -6,6 +6,10 @@ import {
fetchM4ThreatReplayResult,
type M4ThreatReplayResult,
} from "./m4ReplayThreat";
import {
fetchE47SemanticSlamResult,
type E47SemanticSlamResult,
} from "./e47SemanticSlam";
export interface M47ReferenceGraphLabResult {
resultId: string;
@@ -41,6 +45,7 @@ export interface M47ReferenceGraphLabResult {
>>;
limitations: readonly string[];
visual: M4ThreatReplayResult;
semantic: E47SemanticSlamResult;
}
type LaboratoryFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -154,7 +159,7 @@ export async function fetchM47ReferenceGraphLab({
const report = evidence.rawReport;
exact(
report.schema_version,
"missioncore.reference-perception-graph-lab-report/v1",
"missioncore.reference-perception-graph-lab-report/v2",
"M4.7 report schema",
);
exact(report.result_id, resultId, "M4.7 report result");
@@ -176,6 +181,16 @@ export async function fetchM47ReferenceGraphLab({
true,
"M4.7 visual evidence",
);
exact(
visualEvidence.camera_semantic_overlay_available,
true,
"M4.7 camera semantic overlay",
);
exact(
visualEvidence.semantic_binding,
"exact-sequence-and-session-time",
"M4.7 semantic binding",
);
const linkedVisualResultId = text(
visualEvidence.linked_result_id,
"M4.7 linked visual result",
@@ -193,6 +208,31 @@ export async function fetchM47ReferenceGraphLab({
"M4.7 visual binding: сервер вернул другой replay result.",
);
}
const semanticResultId = text(
visualEvidence.semantic_result_id,
"M4.7 linked semantic result",
);
if (!/^e47-semantic-slam-[a-f0-9]{64}$/.test(semanticResultId)) {
throw new M47ReferenceGraphContractError(
"M4.7 semantic binding: нарушена идентичность.",
);
}
const semantic = await fetchE47SemanticSlamResult({
resultId: semanticResultId,
fetcher,
signal,
});
if (
!semantic
|| semantic.resultId !== semanticResultId
|| semantic.baseM4ResultId !== linkedVisualResultId
|| semantic.metrics.frames.total !== 4489
|| semantic.metrics.frames.maskAvailable !== 4489
) {
throw new M47ReferenceGraphContractError(
"M4.7 semantic binding: сервер вернул несвязанный semantic-result.",
);
}
const graphResultId = text(source.graph_result_id, "M4.7 graph result");
if (!/^m47-reference-graph-[a-f0-9]{64}$/.test(graphResultId)) {
throw new M47ReferenceGraphContractError("M4.7 graph result: нарушена идентичность.");
@@ -219,5 +259,6 @@ export async function fetchM47ReferenceGraphLab({
queueHighWatermarks: queueWatermarks(metrics.queue_high_watermarks),
limitations: stringArray(report.limitations, "M4.7 limitations"),
visual,
semantic,
};
}
@@ -44,7 +44,7 @@ export function M47ReferenceGraphResultView({
},
{
label: "Визуал",
value: "VIDEO/CAMERA/3D/PLAN · единый recorded clock · exact M4.6 ledger binding",
value: "VIDEO/CAMERA/3D/PLAN · единый recorded clock · exact M4.6 + E47 semantic binding",
},
]}
brief={{
@@ -72,6 +72,13 @@ export function M47ReferenceGraphResultView({
role: "synchronized VIDEO/CAMERA/3D/PLAN evidence",
identitySha256: result.linkedVisualResultId.split("-").at(-1) ?? null,
},
{
kind: "source",
name: result.semantic.resultId,
version: "4489 exact camera masks",
role: "synchronized diagnostic semantic overlay",
identitySha256: result.semantic.resultId.split("-").at(-1) ?? null,
},
{
kind: "algorithm",
name: "canonical reference perception graph",
@@ -90,7 +97,13 @@ export function M47ReferenceGraphResultView({
kind="diagnostic-model"
resizable
>
<M4ReplayThreatVisual resultId={result.visual.resultId} />
<M4ReplayThreatVisual
resultId={result.visual.resultId}
semantic={{
resultId: result.semantic.resultId,
taxonomy: result.semantic.taxonomy,
}}
/>
</LaboratoryEvidence>
)}
result={(
@@ -127,6 +127,21 @@ test("E47 accepts only a fully accounted diagnostic semantic/SLAM view", async (
);
});
test("E47 fetches one exact content-addressed semantic result", async () => {
const requests = [];
const result = await fetchE47SemanticSlamResult({
resultId,
fetcher: async (input) => {
requests.push(String(input));
return new Response(JSON.stringify(resultView()));
},
});
assert.equal(result.resultId, resultId);
assert.deepEqual(requests, [
`/api/v1/laboratory/e47-semantic-slam/results/${resultId}`,
]);
});
test("E47 rejects result-level point accounting drift", async () => {
await assert.rejects(
fetchE47SemanticSlamResult({
@@ -9,6 +9,7 @@ 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({
@@ -81,6 +82,62 @@ function m4Result() {
};
}
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,
@@ -92,7 +149,7 @@ function evidenceReport() {
threat_assessments: 0,
};
const raw = {
schema_version: "missioncore.reference-perception-graph-lab-report/v1",
schema_version: "missioncore.reference-perception-graph-lab-report/v2",
result_id: resultId,
source: { graph_result_id: graphResultId },
method: { graph_id: "reference-perception-graph/v2" },
@@ -122,8 +179,11 @@ function evidenceReport() {
},
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"],
};
@@ -134,13 +194,13 @@ function evidenceReport() {
created_at_utc: "2026-08-23T18:00:16.061Z",
access: "read-only",
proof: {
document_schema_version: "missioncore.reference-perception-graph-lab/v1",
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: 6,
verified_artifact_count: 6,
artifact_count: 9,
verified_artifact_count: 9,
},
completeness: { identity: "recorded" },
identity: { authority: raw.authority },
@@ -167,14 +227,16 @@ test("M4.7 binds exact Worker graph proof to the synchronized M4.6 visual", asyn
fetcher: async (input) => {
const path = String(input);
requests.push(path);
return new Response(JSON.stringify(
path.includes("/evidence-reports/") ? evidenceReport() : m4Result(),
), { status: 200 });
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));
@@ -182,6 +244,7 @@ test("M4.7 binds exact Worker graph proof to the synchronized M4.6 visual", asyn
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}`,
]);
});
@@ -198,6 +261,9 @@ test("M4.7 keeps exact visual binding during a rolling API deployment", async ()
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()],
@@ -210,5 +276,6 @@ test("M4.7 keeps exact visual binding during a rolling API deployment", async ()
`/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}`,
]);
});