feat(perception): integrate calibrated operator pipeline
Add calibrated K1 projection, recorded and near-live perception qualification, unified Rerun operator layers, bounded replay admission, audited viewer controls, worker experiments, and lab evidence.
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
import k1link.web.camera_archive as camera_archive_module
|
||||
from k1link.device_plugins.xgrids_k1.archive import discover_legacy_viewer_sessions
|
||||
from k1link.web.camera_archive import (
|
||||
CAMERA_ARCHIVE_SCHEMA,
|
||||
@@ -81,6 +82,84 @@ def test_camera_archive_writes_canonical_segments_and_seals_summary(tmp_path: Pa
|
||||
assert writer.close() == summary
|
||||
|
||||
|
||||
def test_recovery_accepts_sealed_index_larger_than_old_duration_cap_without_loading_video(
|
||||
tmp_path: Path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
sessions_root = tmp_path / "sessions"
|
||||
epoch = (
|
||||
sessions_root
|
||||
/ "20260720T065719Z_viewer_live"
|
||||
/ "media"
|
||||
/ "sensor.camera.right"
|
||||
/ "epoch-1"
|
||||
)
|
||||
segments = epoch / "segments"
|
||||
segments.mkdir(parents=True)
|
||||
init = b"sealed-init"
|
||||
(epoch / "init.mp4").write_bytes(init)
|
||||
segment_count = 560
|
||||
segment = b"x"
|
||||
segment_sha256 = hashlib.sha256(segment).hexdigest()
|
||||
index_sha256 = hashlib.sha256()
|
||||
with (epoch / "index.jsonl").open("wb") as stream:
|
||||
for sequence in range(1, segment_count + 1):
|
||||
(segments / f"{sequence}.m4s").write_bytes(segment)
|
||||
line = (
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": "missioncore.camera-recording-index/v1",
|
||||
"sequence": sequence,
|
||||
"kind": "media",
|
||||
"path": f"segments/{sequence}.m4s",
|
||||
"length": 1,
|
||||
"sha256": segment_sha256,
|
||||
"padding": "p" * 60_000,
|
||||
},
|
||||
separators=(",", ":"),
|
||||
)
|
||||
+ "\n"
|
||||
).encode()
|
||||
index_sha256.update(line)
|
||||
stream.write(line)
|
||||
assert (epoch / "index.jsonl").stat().st_size > 32 * 1024 * 1024
|
||||
(epoch / "summary.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"schema_version": CAMERA_ARCHIVE_SCHEMA,
|
||||
"source_id": "sensor.camera.right",
|
||||
"codec_epoch": 1,
|
||||
"status": "complete",
|
||||
"segment_count": segment_count,
|
||||
"entry_count": segment_count,
|
||||
"media_segment_count": segment_count,
|
||||
"valid_bytes": len(init) + segment_count,
|
||||
"init_sha256": hashlib.sha256(init).hexdigest(),
|
||||
"stream_sha256": hashlib.sha256(init + segment * segment_count).hexdigest(),
|
||||
"index_sha256": index_sha256.hexdigest(),
|
||||
"synchronization": "host-arrival-best-effort",
|
||||
"commit_policy": CAMERA_COMMIT_POLICY,
|
||||
"artifacts": {
|
||||
"init": "init.mp4",
|
||||
"segments": "segments",
|
||||
"index": "index.jsonl",
|
||||
},
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
def fail_if_recovery_reads_video(_segments_fd: int) -> object:
|
||||
raise AssertionError("a clean sealed archive must not enter payload recovery")
|
||||
|
||||
monkeypatch.setattr(
|
||||
camera_archive_module,
|
||||
"_read_recovery_segment_catalog",
|
||||
fail_if_recovery_reads_video,
|
||||
)
|
||||
assert recover_incomplete_camera_archives(sessions_root) == ()
|
||||
|
||||
|
||||
def test_camera_archive_rejects_media_without_init_and_existing_epoch(tmp_path: Path) -> None:
|
||||
session = tmp_path / "session"
|
||||
session.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user