feat(observatory): ship modular AI inference labs

This commit is contained in:
DCCONSTRUCTIONS
2026-09-04 17:59:05 +03:00
parent eff60e490a
commit cada687173
145 changed files with 17651 additions and 1667 deletions
+38 -24
View File
@@ -21,6 +21,7 @@ import k1link.laboratory.vegetation_shadow_lab as vegetation_lab_module
import k1link.web.vegetation_shadow_lab_api as vegetation_api_module
from k1link.laboratory import LaboratoryEvidenceRegistry
from k1link.laboratory.canonical_rerun_overlay import (
CANONICAL_REPLAY_RESULT_ID,
CanonicalLabOverlayArtifact,
CanonicalLabReplayArtifact,
_artifact_is_regular,
@@ -69,10 +70,13 @@ def test_canonical_overlay_localizes_current_taxonomies() -> None:
def test_canonical_video_references_hold_only_missing_source_samples() -> None:
session_times = np.arange(10, dtype=np.int64) * 100_000_000 + 39_000_000_000
video_times = np.array(
[0, 100, 200, 300, 400, 500, 600, 700, 900],
dtype=np.int64,
) * 1_000_000
video_times = (
np.array(
[0, 100, 200, 300, 400, 500, 600, 700, 900],
dtype=np.int64,
)
* 1_000_000
)
references = _video_reference_timestamps(video_times, session_times)
@@ -219,6 +223,22 @@ def test_canonical_replay_merges_base_and_overlay_once(
assert calls == 1
def test_canonical_replay_accepts_each_published_portable_result_family() -> None:
suffix = "a" * 64
accepted = {
"lab-v1-vegetation-shadow",
"m49-tgs-portable-review",
"lab-v1-eomt-ddrnet",
"ai-layer-ddrnet",
"ai-layer-eomt",
"ai-layer-rf-detr",
"ai-layer-object-distance",
}
assert all(CANONICAL_REPLAY_RESULT_ID.fullmatch(f"{prefix}-{suffix}") for prefix in accepted)
assert CANONICAL_REPLAY_RESULT_ID.fullmatch(f"ai-layer-unknown-{suffix}") is None
def test_canonical_overlay_get_is_generation_bound_and_range_streamable(
tmp_path: Path,
monkeypatch,
@@ -341,9 +361,7 @@ def test_canonical_overlay_get_is_generation_bound_and_range_streamable(
)
assert stale_overlay.status_code == 412
replay_endpoint = (
f"/api/v1/laboratory/vegetation-shadow/{result_id}/canonical-replay.rrd"
)
replay_endpoint = f"/api/v1/laboratory/vegetation-shadow/{result_id}/canonical-replay.rrd"
replay_descriptor = client.head(
replay_endpoint,
params={"base_generation": generation},
@@ -496,7 +514,9 @@ def _worker_result(root: Path, *, candidate: str, mode: str, vegetation_iou: flo
"truth_pixels": 16384,
"truth_fraction": 0.0625,
"stratum_rank": index + 1,
} if mode == "goose" else None,
}
if mode == "goose"
else None,
"files": files,
}
)
@@ -726,8 +746,7 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
},
]
(full_root / "result.json").write_text(
json.dumps(full_manifest, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
+ "\n",
json.dumps(full_manifest, ensure_ascii=False, sort_keys=True, separators=(",", ":")) + "\n",
encoding="utf-8",
)
for layer, sequence, expected in (
@@ -735,27 +754,24 @@ def test_vegetation_shadow_lab_seals_autonomous_visual_evidence(
("vegetation", 1, full_archive_payloads[1]),
):
response = client.get(
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}"
f"/route-masks/{layer}/{sequence}"
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-masks/{layer}/{sequence}"
)
assert response.status_code == 200
assert response.content == expected
assert response.headers["cache-control"].endswith("immutable")
assert client.get(
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-masks/city/2"
).status_code == 404
timeline = client.get(
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-timeline"
assert (
client.get(
f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-masks/city/2"
).status_code
== 404
)
timeline = client.get(f"/api/v1/laboratory/vegetation-shadow/{full_result_id}/route-timeline")
assert timeline.status_code == 200
assert timeline.content == full_timeline_payload
assert timeline.headers["cache-control"].endswith("immutable")
(result_root / asset_path).write_bytes(b"tampered")
assert (
client.get(f"/api/v1/laboratory/vegetation-shadow/{result_root.name}").status_code
== 503
)
assert client.get(f"/api/v1/laboratory/vegetation-shadow/{result_root.name}").status_code == 503
def test_policy_review_reuses_sealed_video_and_links_yolox_tgs(
@@ -837,9 +853,7 @@ def test_policy_review_reuses_sealed_video_and_links_yolox_tgs(
assert route["linked_tgs_result_id"] == tgs_result_id
assert route["fusion"]["pixel_raster_fusion"] is False
assert route["fusion"]["camera_semantic_temporal_filter"] == "none"
assert route["taxonomy"]["schema_version"] == (
"missioncore.lab-v1-terrain-policy-taxonomy/v1"
)
assert route["taxonomy"]["schema_version"] == ("missioncore.lab-v1-terrain-policy-taxonomy/v1")
assert len(route["taxonomy"]["classes"]) == 10
assert route["valid_fov"]["outside_valid_fov_class_id"] == 9
assert len(manifest["artifacts"]) == 80