refactor(perception): decouple replay from lab layout

This commit is contained in:
DCCONSTRUCTIONS
2026-08-05 14:51:33 +03:00
parent 95ac235122
commit c9242480c2
7 changed files with 159 additions and 26 deletions
+56
View File
@@ -12,6 +12,7 @@ from k1link.perception.baseline import (
load_m4_baseline,
validate_reuse_inventory,
verify_m4_baseline,
verify_m4_execution_source,
)
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
@@ -39,6 +40,61 @@ def test_m4_baseline_is_exact_and_every_local_evidence_digest_resolves() -> None
assert len(verification.verified_paths) == 10
def test_worker_execution_source_verification_needs_no_historical_lab_tree() -> None:
profile = load_m4_baseline(BASELINE_PATH)
camera_root = (
REPOSITORY_ROOT
/ ".runtime/compute-jobs/recorded-camera-602ac89026ed12978619801d"
/ "input/camera/sensor.camera.right/epoch-1"
)
pack_root = (
REPOSITORY_ROOT
/ ".runtime/compute-experiments/e10/lidar-packs"
/ "e10-lidar-pack-576c994a6c814e2592dd6240ace3902a5db94843312c759a73ba0c9166157d2b"
)
verified = verify_m4_execution_source(
profile,
camera_summary_path=camera_root / "summary.json",
camera_index_path=camera_root / "index.jsonl",
source_pack_manifest_path=pack_root / "manifest.json",
source_pack_path=pack_root / "lidar-pack.npz",
)
assert tuple(path.name for path in verified) == (
"summary.json",
"index.jsonl",
"manifest.json",
"lidar-pack.npz",
)
def test_worker_execution_source_rejects_rewritten_manifest_bytes(tmp_path: Path) -> None:
profile = load_m4_baseline(BASELINE_PATH)
camera_root = (
REPOSITORY_ROOT
/ ".runtime/compute-jobs/recorded-camera-602ac89026ed12978619801d"
/ "input/camera/sensor.camera.right/epoch-1"
)
pack_root = (
REPOSITORY_ROOT
/ ".runtime/compute-experiments/e10/lidar-packs"
/ "e10-lidar-pack-576c994a6c814e2592dd6240ace3902a5db94843312c759a73ba0c9166157d2b"
)
rewritten_manifest = tmp_path / "manifest.json"
document = json.loads((pack_root / "manifest.json").read_text("utf-8"))
rewritten_manifest.write_text(json.dumps(document), "utf-8")
with pytest.raises(BaselineContractError, match="manifest file digest"):
verify_m4_execution_source(
profile,
camera_summary_path=camera_root / "summary.json",
camera_index_path=camera_root / "index.jsonl",
source_pack_manifest_path=rewritten_manifest,
source_pack_path=pack_root / "lidar-pack.npz",
)
def test_m4_baseline_cannot_silently_select_another_source(tmp_path: Path) -> None:
document = json.loads(BASELINE_PATH.read_text("utf-8"))
incompatible = copy.deepcopy(document)