fix(lab): стабилизировать нативный RAV004 replay

This commit is contained in:
DCCONSTRUCTIONS
2026-08-30 13:28:33 +03:00
parent f5ee42751d
commit 07453142c2
8 changed files with 418 additions and 17 deletions
+3 -3
View File
@@ -594,9 +594,9 @@ def test_recorded_blueprint_layer_updates_preserve_store_until_explicit_reset(
assert eye_control_updates == [True, False, True, False, True]
assert [activation[1:] for activation in activations] == [
(True, False),
(True, False),
(True, False),
(True, False),
(False, False),
(False, False),
(False, False),
(True, False),
]
assert activations[0][0] is activations[1][0]
+85
View File
@@ -17,6 +17,7 @@ from PIL import Image
import k1link.laboratory.vegetation_policy_review as policy_review_module
import k1link.laboratory.vegetation_policy_video as policy_video_module
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 (
CanonicalLabOverlayArtifact,
@@ -89,6 +90,90 @@ def test_canonical_overlay_memory_cache_rejects_same_size_tampering(
assert not _artifact_is_regular(artifact)
def test_canonical_overlay_get_is_generation_bound_and_range_streamable(
tmp_path: Path,
monkeypatch,
) -> None:
result_id = f"lab-v1-vegetation-shadow-{'a' * 64}"
result_root = tmp_path / result_id
result_root.mkdir()
base = tmp_path / "base.rrd"
base.write_bytes(b"RRF2-base")
overlay = tmp_path / "overlay.rrd"
overlay.write_bytes(b"RRF2-overlay")
generation = "b" * 64
recording_id = "recording-001"
artifact = CanonicalLabOverlayArtifact(
path=overlay,
byte_length=overlay.stat().st_size,
sha256=_sha256(overlay),
)
monkeypatch.setattr(
vegetation_api_module,
"_resolve_candidate",
lambda *_args, **_kwargs: result_root,
)
monkeypatch.setattr(
vegetation_api_module,
"_read_verified",
lambda *_args, **_kwargs: {},
)
monkeypatch.setattr(
vegetation_api_module,
"_full_route_context",
lambda *_args, **_kwargs: ({"session_id": "session-001"}, ()),
)
monkeypatch.setattr(
vegetation_api_module,
"canonical_recording_id",
lambda _path: recording_id,
)
monkeypatch.setattr(
vegetation_api_module,
"canonical_lab_overlay",
lambda *_args, **_kwargs: artifact,
)
ffmpeg = tmp_path / "ffmpeg"
ffmpeg.write_bytes(b"fixture")
ffmpeg.chmod(0o700)
app = FastAPI()
app.include_router(
build_vegetation_shadow_lab_router(
root_provider=lambda: tmp_path,
canonical_recording_provider=lambda _session_id: (base, generation),
jobs_root=tmp_path,
rerun_overlay_cache_root=tmp_path / "cache",
ffmpeg_path=ffmpeg,
)
)
client = TestClient(app)
endpoint = f"/api/v1/laboratory/vegetation-shadow/{result_id}/canonical-overlay.rrd"
response = client.get(
endpoint,
params={
"application_id": "nodedc_mission_core_recorded",
"recording_id": recording_id,
"generation": generation,
},
headers={"Range": "bytes=0-3"},
)
assert response.status_code == 206
assert response.content == b"RRF2"
assert response.headers["content-range"] == f"bytes 0-3/{artifact.byte_length}"
assert response.headers["etag"] == f'"{artifact.sha256}"'
assert response.headers["cache-control"].endswith("immutable")
stale = client.get(
endpoint,
params={
"application_id": "nodedc_mission_core_recorded",
"recording_id": recording_id,
"generation": "c" * 64,
},
)
assert stale.status_code == 412
def test_route_playback_chunk_descriptor_seals_only_requested_binary_window() -> None:
points = np.arange(18, dtype="<f4").reshape(6, 3)
descriptor = _canonical_route_playback_chunk_descriptor(