feat(lab): add recorded realtime spatial playback
This commit is contained in:
@@ -16,6 +16,7 @@ RESULTS_ROOT = REPOSITORY_ROOT / ".runtime/compute-experiments/m4/replay-threat"
|
||||
def _endpoint(path: str, *, camera_frame_provider=None):
|
||||
router = build_m4_threat_replay_router(
|
||||
root_provider=lambda: RESULTS_ROOT,
|
||||
repository_root_provider=lambda: REPOSITORY_ROOT,
|
||||
camera_frame_provider=camera_frame_provider,
|
||||
)
|
||||
return next(
|
||||
@@ -120,16 +121,28 @@ def test_m4_6_lab_api_projects_report_and_exact_visual_frame() -> None:
|
||||
}
|
||||
|
||||
|
||||
def test_m4_6_video_overlay_covers_the_exact_recorded_camera_timeline() -> None:
|
||||
get_overlay = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/video-overlay")
|
||||
def test_m4_6_timeline_is_indexed_and_spatial_evidence_is_chunked() -> None:
|
||||
get_timeline = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/timeline")
|
||||
get_chunk = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/timeline/chunk")
|
||||
|
||||
overlay = get_overlay(RESULT_ID)
|
||||
timeline = get_timeline(RESULT_ID)
|
||||
assert timeline["schema_version"] == "missioncore.recorded-spatial-evidence-timeline/v1"
|
||||
assert timeline["frame_count"] == 4489
|
||||
assert len(timeline["frame_times_ns"]) == 4489
|
||||
assert timeline["recorded_source"]["session_id"] == "20260720T065719Z_viewer_live"
|
||||
assert "frames" not in timeline
|
||||
|
||||
assert overlay["frame_count"] == 4489
|
||||
assert overlay["recorded_source"]["session_id"] == ("20260720T065719Z_viewer_live")
|
||||
assert overlay["frames"][0]["frame_index"] == 0
|
||||
assert overlay["frames"][-1]["frame_index"] == 4488
|
||||
assert overlay["authority"] == "replay-simulated"
|
||||
chunk = get_chunk(RESULT_ID, start=1880, count=12)
|
||||
assert chunk["schema_version"] == "missioncore.recorded-spatial-evidence-chunk/v1"
|
||||
assert chunk["start_sequence"] == 1880
|
||||
assert chunk["frame_count"] == 12
|
||||
assert [frame["sequence"] for frame in chunk["frames"]] == list(range(1880, 1892))
|
||||
first = chunk["frames"][0]
|
||||
assert first["schema_version"] == "missioncore.recorded-spatial-evidence-frame/v1"
|
||||
assert first["spatial_available"] is True
|
||||
assert first["point_cloud_layer"] == "current-increment"
|
||||
assert 0 < first["point_cloud_sample_count"] <= 2000
|
||||
assert first["camera_url"].endswith(f"/{RESULT_ID}/timeline/frames/1880/camera")
|
||||
|
||||
|
||||
def test_m4_6_exact_camera_endpoint_is_bound_to_selected_visual_sequence() -> None:
|
||||
@@ -155,3 +168,26 @@ def test_m4_6_exact_camera_endpoint_is_bound_to_selected_visual_sequence() -> No
|
||||
assert response.media_type == "image/jpeg"
|
||||
assert response.headers["etag"] == f'"{"a" * 64}"'
|
||||
assert calls == [("20260720T065719Z_viewer_live", 2584)]
|
||||
|
||||
|
||||
def test_m4_6_timeline_camera_endpoint_is_bound_to_exact_sequence() -> None:
|
||||
calls: list[tuple[str, int]] = []
|
||||
|
||||
def provide(session_id: str, frame_index: int) -> RecordedCameraFrame:
|
||||
calls.append((session_id, frame_index))
|
||||
return RecordedCameraFrame(
|
||||
payload=b"timeline-jpeg",
|
||||
media_type="image/jpeg",
|
||||
width=800,
|
||||
height=600,
|
||||
sha256="b" * 64,
|
||||
)
|
||||
|
||||
endpoint = _endpoint(
|
||||
"/api/v1/laboratory/m4-threat/results/{result_id}/timeline/frames/{sequence}/camera",
|
||||
camera_frame_provider=provide,
|
||||
)
|
||||
response = endpoint(RESULT_ID, 2584)
|
||||
|
||||
assert response.body == b"timeline-jpeg"
|
||||
assert calls == [("20260720T065719Z_viewer_live", 2584)]
|
||||
|
||||
Reference in New Issue
Block a user