feat(lab): publish M4.7 Worker graph evidence
This commit is contained in:
@@ -127,7 +127,7 @@ def test_product_registry_declares_every_advanced_evidence_source() -> None:
|
||||
repository_root / "config" / "laboratories"
|
||||
)
|
||||
|
||||
assert len(registry.definitions) == 33
|
||||
assert len(registry.definitions) == 34
|
||||
assert {item.work_id for item in registry.definitions} >= {
|
||||
"e31-source-binding",
|
||||
"e46j-raw-fisheye-realtime",
|
||||
@@ -138,4 +138,5 @@ def test_product_registry_declares_every_advanced_evidence_source() -> None:
|
||||
"l33-camera-first-detector-review",
|
||||
"l34f-adjudicated-reference",
|
||||
"m4-replay-threat",
|
||||
"m47-reference-graph-shadow",
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from k1link.laboratory.evidence_registry import LaboratoryEvidenceRegistry
|
||||
from k1link.laboratory.evidence_report import (
|
||||
LaboratoryEvidenceReportService,
|
||||
verify_laboratory_evidence_result,
|
||||
)
|
||||
from k1link.laboratory.m47_reference_graph import (
|
||||
publish_m47_reference_graph_lab,
|
||||
read_m47_reference_graph_lab,
|
||||
)
|
||||
|
||||
|
||||
def _write_json(path: Path, value: object) -> None:
|
||||
path.write_text(json.dumps(value, sort_keys=True, separators=(",", ":")) + "\n")
|
||||
|
||||
|
||||
def test_m47_lab_binds_worker_graph_to_exact_visual_replay(
|
||||
tmp_path: Path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
graph_root = tmp_path / "graph"
|
||||
visual_root = tmp_path / "visual"
|
||||
graph_root.mkdir()
|
||||
visual_root.mkdir()
|
||||
runtime = {
|
||||
"schema_version": "missioncore.reference-graph-runtime-identity/v3",
|
||||
"worker_id": "worker-006",
|
||||
"worker_node": "DESKTOP-OPJ8J04",
|
||||
"worker_container_id": "a" * 64,
|
||||
"worker_image_id": "sha256:" + "b" * 64,
|
||||
"isolated_triton_container_id": "c" * 64,
|
||||
"isolated_triton_image_id": "sha256:" + "b" * 64,
|
||||
"historical_worker_container_id": "d" * 64,
|
||||
"historical_worker_running": False,
|
||||
"historical_triton_container_id": "e" * 64,
|
||||
"historical_triton_running": False,
|
||||
"artifact_sha256": "f" * 64,
|
||||
"patch_id": "mission-core-m47-test",
|
||||
"code_revision": "1" * 40,
|
||||
"graph_id": "reference-perception-graph/v2",
|
||||
"started_at_utc": "2026-08-23T18:00:16.061Z",
|
||||
"source_mount_read_only": True,
|
||||
"isolated_model_service": True,
|
||||
"public_worker_port_added": False,
|
||||
"commands_enabled": False,
|
||||
"actuation_allowed": False,
|
||||
}
|
||||
mismatch_counts = {
|
||||
"source_binding": 0,
|
||||
"current": 0,
|
||||
"rolling_retained": 0,
|
||||
"held": 0,
|
||||
"expired": 0,
|
||||
"camera_uncertainty": 0,
|
||||
"threat_assessments": 0,
|
||||
}
|
||||
graph_manifest = {
|
||||
"schema_version": "missioncore.reference-perception-graph-manifest/v1",
|
||||
"graph_id": "reference-perception-graph/v2",
|
||||
"source_profile_id": "m4-ravnoves00-recorded-realtime/v1",
|
||||
"run_mode": "lossless-replay",
|
||||
"canonical_payload_sha256": "2" * 64,
|
||||
"runtime": runtime,
|
||||
}
|
||||
graph_report = {
|
||||
"schema_version": "missioncore.reference-perception-graph-report/v1",
|
||||
"admitted_frames": 4489,
|
||||
"terminal_outcomes": {"delivered": 4489},
|
||||
"queue_high_watermarks": {
|
||||
"detector": 2,
|
||||
"geometry": 2,
|
||||
"temporal": 2,
|
||||
"rolling": 2,
|
||||
"threat": 2,
|
||||
},
|
||||
"accepted_parity": {
|
||||
"schema_version": "missioncore.reference-perception-graph-parity/v1",
|
||||
"accepted": True,
|
||||
"expected_frames": 4489,
|
||||
"compared_frames": 4489,
|
||||
"temporal_frames_sha256": "3" * 64,
|
||||
"threat_frames_sha256": "4" * 64,
|
||||
"mismatch_counts": mismatch_counts,
|
||||
},
|
||||
"execution": {"elapsed_seconds": 198.0, "runtime_identity": runtime},
|
||||
"gates": {"accepted": True},
|
||||
}
|
||||
visual_manifest = {
|
||||
"schema_version": "missioncore.perception-threat-replay-result/v2",
|
||||
"identity": {
|
||||
"source_session_id": "20260720T065719Z_viewer_live",
|
||||
"frames_sha256": "4" * 64,
|
||||
"temporal_frames_sha256": "3" * 64,
|
||||
},
|
||||
}
|
||||
visual_report = {"schema_version": "missioncore.perception-threat-replay-report/v2"}
|
||||
for root, documents in (
|
||||
(
|
||||
graph_root,
|
||||
{
|
||||
"manifest.json": graph_manifest,
|
||||
"report.json": graph_report,
|
||||
"runtime.json": runtime,
|
||||
},
|
||||
),
|
||||
(
|
||||
visual_root,
|
||||
{"manifest.json": visual_manifest, "report.json": visual_report},
|
||||
),
|
||||
):
|
||||
for name, document in documents.items():
|
||||
_write_json(root / name, document)
|
||||
graph = SimpleNamespace(
|
||||
accepted=True,
|
||||
result_id="m47-reference-graph-" + "5" * 64,
|
||||
result_root=graph_root,
|
||||
manifest=graph_manifest,
|
||||
report=graph_report,
|
||||
)
|
||||
visual = SimpleNamespace(
|
||||
accepted=True,
|
||||
result_id="m4-threat-replay-" + "6" * 64,
|
||||
result_root=visual_root,
|
||||
manifest=visual_manifest,
|
||||
report=visual_report,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"k1link.laboratory.m47_reference_graph.read_reference_graph_result",
|
||||
lambda _: graph,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"k1link.laboratory.m47_reference_graph.read_threat_replay_result",
|
||||
lambda _: visual,
|
||||
)
|
||||
|
||||
runtime_root = tmp_path / "runtime"
|
||||
result = publish_m47_reference_graph_lab(
|
||||
graph_result_root=graph_root,
|
||||
visual_result_root=visual_root,
|
||||
output_root=runtime_root / "m47" / "reference-graph-labs",
|
||||
)
|
||||
|
||||
assert read_m47_reference_graph_lab(result.result_root) == result
|
||||
assert result.report["visual_evidence"]["linked_result_id"] == visual.result_id
|
||||
assert result.report["execution"]["worker_id"] == "worker-006"
|
||||
assert result.report["metrics"]["parity_mismatch_counts"] == mismatch_counts
|
||||
repository_root = Path(__file__).resolve().parents[1]
|
||||
registry = LaboratoryEvidenceRegistry.from_directory(
|
||||
repository_root / "config" / "laboratories"
|
||||
)
|
||||
definition = next(
|
||||
item for item in registry.definitions if item.work_id == "m47-reference-graph-shadow"
|
||||
)
|
||||
proof = verify_laboratory_evidence_result(definition, result.result_root)
|
||||
assert proof["artifact_count"] == 6
|
||||
projected = LaboratoryEvidenceReportService(registry, lambda: runtime_root).read(
|
||||
definition.work_id,
|
||||
result.result_id,
|
||||
)
|
||||
assert projected["raw_report"]["schema_version"] == (
|
||||
"missioncore.reference-perception-graph-lab-report/v1"
|
||||
)
|
||||
@@ -100,11 +100,13 @@ def test_threat_result_is_content_bound_and_visual_evidence_is_complete() -> Non
|
||||
|
||||
def test_m4_6_lab_api_projects_report_and_exact_visual_frame() -> None:
|
||||
list_results = _endpoint("/api/v1/laboratory/m4-threat/results")
|
||||
get_result = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}")
|
||||
list_visuals = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/visuals")
|
||||
get_visual = _endpoint("/api/v1/laboratory/m4-threat/results/{result_id}/visuals/{ordinal}")
|
||||
|
||||
catalog = list_results(limit=1)
|
||||
assert catalog["items"][0]["result_id"] == RESULT_ID
|
||||
assert get_result(RESULT_ID) == catalog["items"][0]
|
||||
assert catalog["items"][0]["authority"] == "replay-simulated"
|
||||
visuals = list_visuals(RESULT_ID)
|
||||
assert len(visuals["items"]) == 32
|
||||
|
||||
@@ -16,7 +16,10 @@ from k1link.perception.graph_contracts import (
|
||||
from k1link.perception.providers import ReferencePerceptionGraphConfigV2
|
||||
from k1link.perception.reference_graph_identity import ReferenceGraphRuntimeIdentity
|
||||
from k1link.perception.reference_graph_parity import ReferenceGraphParityReport
|
||||
from k1link.perception.reference_graph_result import seal_reference_graph_result
|
||||
from k1link.perception.reference_graph_result import (
|
||||
read_reference_graph_result,
|
||||
seal_reference_graph_result,
|
||||
)
|
||||
|
||||
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -174,6 +177,7 @@ def test_reference_graph_result_is_content_addressed_and_reproducible(tmp_path:
|
||||
assert runtime == _runtime().to_dict()
|
||||
assert first.manifest["runtime"] == runtime
|
||||
assert first.manifest["files"]["runtime.json"]["sha256"]
|
||||
assert read_reference_graph_result(first.result_root) == first
|
||||
|
||||
|
||||
def test_reference_graph_result_fails_closed_on_supersession(tmp_path: Path) -> None:
|
||||
|
||||
Reference in New Issue
Block a user