fix(perception): bound LAB replay to AI window
This commit is contained in:
@@ -37,6 +37,9 @@ def test_publish_lab_replay_cache_hardlinks_rrd_and_rebinds_sidecars(
|
||||
"recording_byte_length": source_rrd.stat().st_size,
|
||||
"recording_mtime_ns": source_rrd.stat().st_mtime_ns,
|
||||
"recording_sha256": hashlib.sha256(source_rrd.read_bytes()).hexdigest(),
|
||||
"timeline": "session_time",
|
||||
"timeline_start_ns": 0,
|
||||
"timeline_end_ns": 1,
|
||||
}
|
||||
(source / RECORDING_CACHE_SIDECAR_FILENAME).write_text(
|
||||
json.dumps(source_sidecar),
|
||||
@@ -87,3 +90,81 @@ def test_publish_lab_replay_cache_hardlinks_rrd_and_rebinds_sidecars(
|
||||
|
||||
lab_rrd.unlink()
|
||||
assert source_rrd.read_bytes() == b"RRF2immutable"
|
||||
|
||||
|
||||
def test_publish_lab_replay_cache_materializes_exact_bounded_window(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
import numpy as np
|
||||
import rerun as rr
|
||||
|
||||
data = tmp_path / "mission-core"
|
||||
recordings = data / "recordings"
|
||||
source = recordings / "source-session"
|
||||
source.mkdir(parents=True)
|
||||
source_rrd = source / RECORDING_CACHE_FILENAME
|
||||
recording = rr.RecordingStream(
|
||||
"nodedc_mission_core_recorded",
|
||||
recording_id=source.name,
|
||||
)
|
||||
stream = rr.binary_stream(recording)
|
||||
try:
|
||||
for index, timestamp in enumerate((0, 2_000_000_000, 4_000_000_000, 8_000_000_000)):
|
||||
recording.set_time(
|
||||
"session_time",
|
||||
duration=np.timedelta64(timestamp, "ns"),
|
||||
)
|
||||
recording.log(
|
||||
"/world/points",
|
||||
rr.Points3D([[float(index), 0.0, 0.0]]),
|
||||
)
|
||||
payload = stream.read(flush=True, flush_timeout_sec=5.0)
|
||||
finally:
|
||||
recording.disconnect()
|
||||
assert payload is not None
|
||||
source_rrd.write_bytes(payload)
|
||||
source_sidecar = {
|
||||
"schema_version": CACHE_SCHEMA,
|
||||
"session_id": source.name,
|
||||
"recording_byte_length": source_rrd.stat().st_size,
|
||||
"recording_mtime_ns": source_rrd.stat().st_mtime_ns,
|
||||
"recording_sha256": hashlib.sha256(source_rrd.read_bytes()).hexdigest(),
|
||||
"timeline": "session_time",
|
||||
"timeline_start_ns": 0,
|
||||
"timeline_end_ns": 8_000_000_000,
|
||||
}
|
||||
(source / RECORDING_CACHE_SIDECAR_FILENAME).write_text(
|
||||
json.dumps(source_sidecar),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
publish_lab_replay_cache(
|
||||
data,
|
||||
source_session_id=source.name,
|
||||
lab_session_id="lab-e21-bounded",
|
||||
timeline_start_ns=2_000_000_000,
|
||||
timeline_end_ns=4_000_000_000,
|
||||
)
|
||||
|
||||
lab = recordings / "lab-e21-bounded"
|
||||
lab_rrd = lab / RECORDING_CACHE_FILENAME
|
||||
assert lab_rrd.stat().st_ino != source_rrd.stat().st_ino
|
||||
bounded = json.loads(
|
||||
(lab / RECORDING_CACHE_SIDECAR_FILENAME).read_text(encoding="utf-8")
|
||||
)
|
||||
assert bounded["timeline_start_ns"] == 2_000_000_000
|
||||
assert bounded["timeline_end_ns"] == 4_000_000_000
|
||||
assert bounded["recording_byte_length"] == lab_rrd.stat().st_size
|
||||
assert bounded["recording_sha256"] == hashlib.sha256(lab_rrd.read_bytes()).hexdigest()
|
||||
assert "lab_window" not in bounded
|
||||
|
||||
original_stat = lab_rrd.stat()
|
||||
publish_lab_replay_cache(
|
||||
data,
|
||||
source_session_id=source.name,
|
||||
lab_session_id="lab-e21-bounded",
|
||||
timeline_start_ns=2_000_000_000,
|
||||
timeline_end_ns=4_000_000_000,
|
||||
)
|
||||
assert lab_rrd.stat().st_ino == original_stat.st_ino
|
||||
assert lab_rrd.stat().st_mtime_ns == original_stat.st_mtime_ns
|
||||
|
||||
@@ -849,6 +849,38 @@ def test_lab_instance_publication_is_idempotent_but_provenance_is_immutable(
|
||||
store.publish_lab_instance(**{**parameters, "config_sha256": "0" * 64})
|
||||
|
||||
|
||||
def test_bounded_lab_instance_excludes_unbounded_recorded_media(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
repository = tmp_path / "repo"
|
||||
sessions = repository / "sessions"
|
||||
source = make_legacy_session(sessions, "20260716T205632Z_viewer_live")
|
||||
make_recorded_camera_source(source)
|
||||
store = SessionStore(repository, data_dir=tmp_path / "data")
|
||||
store.reconcile_archive(xgrids_k1_archive_source(sessions))
|
||||
assert store.list_recorded_media(source.name)
|
||||
|
||||
binding = store.publish_lab_instance(
|
||||
session_id="lab-e21-window-d0201712",
|
||||
source_session_id=source.name,
|
||||
display_name="LAB E21.2 · bounded 60s",
|
||||
lab_id="LAB E21.2",
|
||||
result_kind="e21-realtime-envelope",
|
||||
result_id="e10-integrated-perception-" + "1" * 64,
|
||||
source_result_id="e21-realtime-envelope-" + "2" * 64,
|
||||
config_sha256="3" * 64,
|
||||
run_created_at_utc="2026-07-23T15:55:15.548Z",
|
||||
duration_seconds=59.962,
|
||||
include_recorded_media=False,
|
||||
provenance={"timeline_scope": "bounded"},
|
||||
)
|
||||
|
||||
detail = store.get_session(binding.session_id)
|
||||
assert detail.summary.duration_seconds == pytest.approx(59.962)
|
||||
assert store.list_recorded_media(binding.session_id) == ()
|
||||
assert store.prepare_replay(binding.session_id).primary_artifact.path.is_file()
|
||||
|
||||
|
||||
def test_delete_session_rejects_a_catalog_target_outside_its_allowed_root(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user