feat(perception): qualify inline temporal stability
This commit is contained in:
@@ -22,6 +22,7 @@ from k1link.sessions import (
|
||||
publish_lab_replay_cache,
|
||||
)
|
||||
|
||||
from .inline_temporal import StreamingSemanticStabilizer, read_inline_profile
|
||||
from .integrated_perception import (
|
||||
IntegratedPerceptionResult,
|
||||
validate_integrated_perception_result,
|
||||
@@ -29,6 +30,7 @@ from .integrated_perception import (
|
||||
from .jobs import CameraComputeJob, validate_camera_compute_job
|
||||
from .temporal_stability import (
|
||||
TemporalStabilityBuild,
|
||||
_quality_metrics,
|
||||
build_temporal_stability_result,
|
||||
)
|
||||
|
||||
@@ -224,9 +226,7 @@ def publish_e21_lab_instance(
|
||||
source_result_id=str(e21_document["result_id"]),
|
||||
config_sha256=str(e21_report["identity"]["profile_sha256"]),
|
||||
run_created_at_utc=str(e21_report["created_at_utc"]),
|
||||
duration_seconds=(
|
||||
validated.timeline_end_seconds - validated.timeline_start_seconds
|
||||
),
|
||||
duration_seconds=(validated.timeline_end_seconds - validated.timeline_start_seconds),
|
||||
include_recorded_media=False,
|
||||
provenance={
|
||||
"schema_version": "missioncore.e21-lab-publication/v1",
|
||||
@@ -297,20 +297,14 @@ def publish_e22_lab_instance(
|
||||
)
|
||||
if not validated.accepted:
|
||||
failed = [
|
||||
name
|
||||
for name, accepted in build.report["acceptance"]["checks"].items()
|
||||
if not accepted
|
||||
name for name, accepted in build.report["acceptance"]["checks"].items() if not accepted
|
||||
]
|
||||
raise SessionIntegrityError(
|
||||
f"E22 temporal acceptance failed: {', '.join(failed)}"
|
||||
)
|
||||
raise SessionIntegrityError(f"E22 temporal acceptance failed: {', '.join(failed)}")
|
||||
|
||||
store = SessionStore(root)
|
||||
source_lab = store.get_lab_instance(source.job.session_id)
|
||||
source_session_id = (
|
||||
source.job.session_id
|
||||
if source_lab is None
|
||||
else source_lab.source_session_id
|
||||
source.job.session_id if source_lab is None else source_lab.source_session_id
|
||||
)
|
||||
publish_lab_replay_cache(
|
||||
store.data_dir,
|
||||
@@ -330,26 +324,22 @@ def publish_e22_lab_instance(
|
||||
source_result_id=source.result_id,
|
||||
config_sha256=build.profile_sha256,
|
||||
run_created_at_utc=validated.created_at_utc,
|
||||
duration_seconds=(
|
||||
validated.timeline_end_seconds - validated.timeline_start_seconds
|
||||
),
|
||||
duration_seconds=(validated.timeline_end_seconds - validated.timeline_start_seconds),
|
||||
include_recorded_media=False,
|
||||
provenance={
|
||||
"schema_version": "missioncore.e22-lab-publication/v1",
|
||||
"storage_mode": "bounded-derived-replay-and-temporal-projection",
|
||||
"source_result_id": source.result_id,
|
||||
"source_lab_session_id": (
|
||||
None if source_lab is None else source_lab.session_id
|
||||
),
|
||||
"source_lab_session_id": (None if source_lab is None else source_lab.session_id),
|
||||
"source_payloads_mutated": False,
|
||||
"lookahead_frames": 0,
|
||||
"peak_track_states": metrics["runtime"]["peak_track_states"],
|
||||
"camera_frame_processing_p95_ms": metrics["runtime"][
|
||||
"camera_frame_processing_ms"
|
||||
]["p95"],
|
||||
"semantic_frame_processing_p95_ms": metrics["runtime"][
|
||||
"semantic_frame_processing_ms"
|
||||
]["p95"],
|
||||
"camera_frame_processing_p95_ms": metrics["runtime"]["camera_frame_processing_ms"][
|
||||
"p95"
|
||||
],
|
||||
"semantic_frame_processing_p95_ms": metrics["runtime"]["semantic_frame_processing_ms"][
|
||||
"p95"
|
||||
],
|
||||
"quality_reductions": metrics["reductions"],
|
||||
},
|
||||
)
|
||||
@@ -361,6 +351,210 @@ def publish_e22_lab_instance(
|
||||
)
|
||||
|
||||
|
||||
def publish_e23_lab_instance(
|
||||
*,
|
||||
repository_root: Path,
|
||||
reference_result_root: Path,
|
||||
worker_result_root: Path,
|
||||
source_report_path: Path,
|
||||
profile_path: Path,
|
||||
lab_session_id: str,
|
||||
lab_id: str,
|
||||
display_name: str,
|
||||
) -> PublishedIntegratedLabInstance:
|
||||
"""Publish one accepted inline-temporal 1x worker run as an exact LAB replay."""
|
||||
|
||||
root = repository_root.expanduser().resolve(strict=True)
|
||||
jobs_root = root / ".runtime" / "compute-jobs"
|
||||
results_root = root / ".runtime" / "compute-experiments" / "e10" / "worker-results"
|
||||
packs_root = root / ".runtime" / "compute-experiments" / "e10" / "lidar-packs"
|
||||
reference_path = reference_result_root.expanduser().resolve(strict=True)
|
||||
reference_document = _read_object(reference_path / "result.json", reference_path)
|
||||
reference_identity = reference_document.get("identity")
|
||||
if not isinstance(reference_identity, dict) or not isinstance(
|
||||
reference_identity.get("job_id"), str
|
||||
):
|
||||
raise SessionIntegrityError("E23 semantic reference has no job identity")
|
||||
reference = validate_integrated_perception_result(
|
||||
jobs_root / reference_identity["job_id"],
|
||||
reference_path,
|
||||
packs_root,
|
||||
)
|
||||
if not reference.accepted or reference.source_start_frame_index != 0:
|
||||
raise SessionIntegrityError("E23 reference is not an accepted zero-based run")
|
||||
|
||||
profile, profile_sha256 = read_inline_profile(profile_path)
|
||||
worker_root = worker_result_root.expanduser().resolve(strict=True)
|
||||
source_path = source_report_path.expanduser().resolve(strict=True)
|
||||
worker_document, worker_report, source_report = _validate_e23_inputs(
|
||||
worker_root,
|
||||
source_path,
|
||||
profile_sha256,
|
||||
)
|
||||
frame_count = int(source_report["events_selected"]["camera-frame"])
|
||||
if frame_count != reference.frame_count:
|
||||
raise SessionIntegrityError("E23 source and reference frame counts differ")
|
||||
|
||||
lab_job = _publish_lab_job(reference.job, jobs_root, lab_session_id)
|
||||
lab_pack = _publish_e21_pack(
|
||||
reference,
|
||||
lab_job,
|
||||
packs_root,
|
||||
lab_session_id,
|
||||
frame_count,
|
||||
visual_projection="accepted-e23-inline-envelope/v1",
|
||||
)
|
||||
lab_result, quality = _publish_e23_visual_result(
|
||||
reference=reference,
|
||||
lab_job=lab_job,
|
||||
lab_pack=lab_pack,
|
||||
results_root=results_root,
|
||||
lab_session_id=lab_session_id,
|
||||
frame_count=frame_count,
|
||||
worker_root=worker_root,
|
||||
worker_document=worker_document,
|
||||
worker_report=worker_report,
|
||||
source_report=source_report,
|
||||
profile=profile,
|
||||
profile_sha256=profile_sha256,
|
||||
)
|
||||
validated = validate_integrated_perception_result(
|
||||
lab_job.job_root,
|
||||
lab_result,
|
||||
packs_root,
|
||||
)
|
||||
if not validated.accepted or not all(quality["checks"].values()):
|
||||
failed = [name for name, accepted in quality["checks"].items() if not accepted]
|
||||
raise SessionIntegrityError(f"E23 inline temporal acceptance failed: {', '.join(failed)}")
|
||||
|
||||
store = SessionStore(root)
|
||||
source_lab = store.get_lab_instance(reference.job.session_id)
|
||||
source_session_id = (
|
||||
reference.job.session_id if source_lab is None else source_lab.source_session_id
|
||||
)
|
||||
publish_lab_replay_cache(
|
||||
store.data_dir,
|
||||
source_session_id=source_session_id,
|
||||
lab_session_id=lab_session_id,
|
||||
timeline_start_ns=round(validated.timeline_start_seconds * 1_000_000_000),
|
||||
timeline_end_ns=round(validated.timeline_end_seconds * 1_000_000_000),
|
||||
)
|
||||
temporal = worker_report["metrics"]["temporal_stability"]
|
||||
binding = store.publish_lab_instance(
|
||||
session_id=lab_session_id,
|
||||
source_session_id=source_session_id,
|
||||
display_name=display_name,
|
||||
lab_id=lab_id,
|
||||
result_kind="e23-inline-temporal-stability",
|
||||
result_id=validated.result_id,
|
||||
source_result_id=str(worker_document["result_id"]),
|
||||
config_sha256=profile_sha256,
|
||||
run_created_at_utc=str(worker_report["created_at_utc"]),
|
||||
duration_seconds=(validated.timeline_end_seconds - validated.timeline_start_seconds),
|
||||
include_recorded_media=False,
|
||||
provenance={
|
||||
"schema_version": "missioncore.e23-lab-publication/v1",
|
||||
"storage_mode": "bounded-inline-worker-result-and-immutable-source-replay",
|
||||
"worker_result_id": worker_document["result_id"],
|
||||
"source_report_sha256": _sha256(source_path),
|
||||
"reference_result_id": reference.result_id,
|
||||
"source_payloads_mutated": False,
|
||||
"lookahead_frames": 0,
|
||||
"speed": 1.0,
|
||||
"quality_reductions": quality["reductions"],
|
||||
"temporal_2d_3d_p95_ms": worker_report["metrics"]["latency_ms"]["temporal_2d_3d_ms"][
|
||||
"p95"
|
||||
],
|
||||
"semantic_temporal_p95_ms": temporal["semantic"]["processing_ms"]["p95"],
|
||||
"peak_track_states": temporal["tracking_2d_3d"]["peak_track_states"],
|
||||
"rss_growth_mib": worker_report["metrics"]["runtime_telemetry"]["rss_growth_mib"],
|
||||
},
|
||||
)
|
||||
return PublishedIntegratedLabInstance(
|
||||
binding=binding,
|
||||
job=lab_job,
|
||||
result=validated,
|
||||
)
|
||||
|
||||
|
||||
def _validate_e23_inputs(
|
||||
worker_root: Path,
|
||||
source_report_path: Path,
|
||||
profile_sha256: str,
|
||||
) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:
|
||||
worker_document = _read_object(worker_root / "result.json", worker_root)
|
||||
worker_report = _read_object(worker_root / "run-report.json", worker_root)
|
||||
source_report = _read_object(source_report_path, source_report_path.parent)
|
||||
worker_identity = worker_document.get("identity")
|
||||
report_identity = worker_report.get("identity")
|
||||
if (
|
||||
worker_document.get("schema_version") != "missioncore.e15-shadow-inference-result/v1"
|
||||
or worker_document.get("result_id") != worker_root.name
|
||||
or worker_document.get("acceptance_state") != "accepted"
|
||||
or worker_document.get("publication_scope") != "live-shadow-diagnostic-only"
|
||||
or not isinstance(worker_identity, dict)
|
||||
or worker_identity.get("pipeline")
|
||||
!= "warm-worker-inline-bounded-temporal-2d-3d-semantic/v1"
|
||||
or worker_identity.get("profiles", {}).get("stability_sha256") != profile_sha256
|
||||
or worker_report.get("schema_version") != "missioncore.e15-shadow-inference-report/v1"
|
||||
or worker_report.get("result_id") != worker_root.name
|
||||
or worker_report.get("state") != "accepted"
|
||||
or report_identity != worker_identity
|
||||
or not all(worker_report.get("acceptance", {}).get("checks", {}).values())
|
||||
or source_report.get("schema_version") != "missioncore.e23-replay-source-report/v1"
|
||||
or source_report.get("state") != "completed"
|
||||
or source_report.get("session_id") != worker_identity.get("session_id")
|
||||
or source_report.get("source", {}).get("speed") != 1.0
|
||||
or source_report.get("authority", {}).get("mode") != "shadow-diagnostic-only"
|
||||
or source_report.get("authority", {}).get("commands_enabled") is not False
|
||||
or source_report.get("authority", {}).get("navigation_or_safety_accepted") is not False
|
||||
):
|
||||
raise SessionIntegrityError("E23 accepted worker/source identity is inconsistent")
|
||||
selected = source_report.get("events_selected")
|
||||
diagnostics = source_report.get("diagnostic_results")
|
||||
if (
|
||||
not isinstance(selected, dict)
|
||||
or selected.get("camera-frame") != 601
|
||||
or selected.get("lidar") != 585
|
||||
or selected.get("pose") != 600
|
||||
or not isinstance(diagnostics, dict)
|
||||
or int(diagnostics.get("received", 0)) < 590
|
||||
):
|
||||
raise SessionIntegrityError("E23 source replay coverage is incomplete")
|
||||
|
||||
required = {
|
||||
"e15-semantic-frames": "semantic-frames.jsonl",
|
||||
"e23-raw-fusion-frames": "raw-fusion-frames.jsonl",
|
||||
"e15-fusion-frames": "fusion-frames.jsonl",
|
||||
"e15-world-state": "world-state.jsonl",
|
||||
"worker-gpu-telemetry": "gpu-telemetry.jsonl",
|
||||
"worker-runtime-telemetry": "runtime-telemetry.jsonl",
|
||||
"e15-run-report": "run-report.json",
|
||||
}
|
||||
artifacts = worker_document.get("artifacts")
|
||||
descriptors = (
|
||||
{
|
||||
value.get("kind"): value
|
||||
for value in artifacts
|
||||
if isinstance(value, dict) and value.get("kind") in required
|
||||
}
|
||||
if isinstance(artifacts, list)
|
||||
else {}
|
||||
)
|
||||
if set(descriptors) != set(required):
|
||||
raise SessionIntegrityError("E23 worker artifacts are incomplete")
|
||||
for kind, name in required.items():
|
||||
descriptor = descriptors[kind]
|
||||
path = worker_root / name
|
||||
if (
|
||||
descriptor.get("path") != name
|
||||
or descriptor.get("byte_length") != path.stat().st_size
|
||||
or descriptor.get("sha256") != _sha256(path)
|
||||
):
|
||||
raise SessionIntegrityError("E23 worker artifact identity changed")
|
||||
return worker_document, worker_report, source_report
|
||||
|
||||
|
||||
def _validate_e21_inputs(
|
||||
e21_root: Path,
|
||||
worker_root: Path,
|
||||
@@ -426,6 +620,8 @@ def _publish_e21_pack(
|
||||
packs_root: Path,
|
||||
lab_session_id: str,
|
||||
frame_count: int,
|
||||
*,
|
||||
visual_projection: str = "accepted-e21-envelope/v1",
|
||||
) -> Path:
|
||||
source_manifest = _read_object(reference.pack_root / "manifest.json", reference.pack_root)
|
||||
with np.load(reference.pack_root / "lidar-pack.npz", allow_pickle=False) as arrays:
|
||||
@@ -438,9 +634,9 @@ def _publish_e21_pack(
|
||||
"cloud_offsets": arrays["cloud_offsets"][: frame_count + 1].copy(),
|
||||
"cloud_points_map": arrays["cloud_points_map"][:cloud_end].copy(),
|
||||
"pose_positions_map": arrays["pose_positions_map"][:frame_count].copy(),
|
||||
"pose_quaternions_map_from_lidar": arrays[
|
||||
"pose_quaternions_map_from_lidar"
|
||||
][:frame_count].copy(),
|
||||
"pose_quaternions_map_from_lidar": arrays["pose_quaternions_map_from_lidar"][
|
||||
:frame_count
|
||||
].copy(),
|
||||
"lidar_camera_delta_ms": arrays["lidar_camera_delta_ms"][:frame_count].copy(),
|
||||
"pose_point_delta_ms": arrays["pose_point_delta_ms"][:frame_count].copy(),
|
||||
"intrinsic_fx_fy_cx_cy": arrays["intrinsic_fx_fy_cx_cy"].copy(),
|
||||
@@ -460,7 +656,7 @@ def _publish_e21_pack(
|
||||
"point_count": int(payload["cloud_points_map"].shape[0]),
|
||||
"timeline_start_seconds": float(payload["session_seconds"][0]),
|
||||
"timeline_end_seconds": float(payload["session_seconds"][-1]),
|
||||
"visual_projection": "accepted-e21-envelope/v1",
|
||||
"visual_projection": visual_projection,
|
||||
}
|
||||
)
|
||||
identity_sha256 = hashlib.sha256(_canonical_json(identity)).hexdigest()
|
||||
@@ -580,9 +776,7 @@ def _publish_e21_visual_result(
|
||||
)
|
||||
fusion_rows.append(normalized_fusion)
|
||||
world_rows.append(normalized_world)
|
||||
expected_drops = int(
|
||||
e21_report["metrics"]["worker"]["detector"]["queue"]["dropped_overflow"]
|
||||
)
|
||||
expected_drops = int(e21_report["metrics"]["worker"]["detector"]["queue"]["dropped_overflow"])
|
||||
if len(dropped_indices) != expected_drops:
|
||||
raise SessionIntegrityError("E21 detector replacement accounting changed")
|
||||
|
||||
@@ -762,6 +956,329 @@ def _publish_e21_visual_result(
|
||||
return destination
|
||||
|
||||
|
||||
def _publish_e23_visual_result(
|
||||
*,
|
||||
reference: IntegratedPerceptionResult,
|
||||
lab_job: CameraComputeJob,
|
||||
lab_pack: Path,
|
||||
results_root: Path,
|
||||
lab_session_id: str,
|
||||
frame_count: int,
|
||||
worker_root: Path,
|
||||
worker_document: dict[str, Any],
|
||||
worker_report: dict[str, Any],
|
||||
source_report: dict[str, Any],
|
||||
profile: dict[str, Any],
|
||||
profile_sha256: str,
|
||||
) -> tuple[Path, dict[str, Any]]:
|
||||
with np.load(reference.arrays_path, allow_pickle=False) as arrays:
|
||||
frame_times = arrays["frame_times_ns"][:frame_count].copy()
|
||||
reference_semantic_indices = arrays["semantic_frame_indices"]
|
||||
selected = reference_semantic_indices < frame_count
|
||||
reference_indices = reference_semantic_indices[selected].copy()
|
||||
reference_masks = arrays["semantic_masks"][selected].copy()
|
||||
|
||||
semantic_rows = _read_jsonl(worker_root / "semantic-frames.jsonl")
|
||||
if [row.get("frame_index") for row in semantic_rows] != reference_indices.tolist():
|
||||
raise SessionIntegrityError("E23 semantic frame schedule changed")
|
||||
semantic_stabilizer = StreamingSemanticStabilizer(profile)
|
||||
stabilized_masks = np.stack(
|
||||
[semantic_stabilizer.update(mask) for mask in reference_masks]
|
||||
).astype(np.uint8, copy=False)
|
||||
for row, mask in zip(semantic_rows, stabilized_masks, strict=True):
|
||||
if row.get("mask_sha256") != hashlib.sha256(mask.tobytes()).hexdigest():
|
||||
raise SessionIntegrityError("E23 semantic mask does not match inline reconstruction")
|
||||
row["schema_version"] = "missioncore.e10-semantic-frame/v1"
|
||||
row["session_seconds"] = float(frame_times[int(row["frame_index"])]) / 1_000_000_000
|
||||
row["temporal_status"] = "e23-inline-spatially-supported-hysteresis"
|
||||
|
||||
raw_worker_rows = _read_jsonl(worker_root / "raw-fusion-frames.jsonl")
|
||||
stable_worker_rows = _read_jsonl(worker_root / "fusion-frames.jsonl")
|
||||
fusion_source = {int(row["source_frame_index"]): row for row in stable_worker_rows}
|
||||
world_source = {
|
||||
int(row["source_frame_index"]): row
|
||||
for row in _read_jsonl(worker_root / "world-state.jsonl")
|
||||
}
|
||||
if set(fusion_source) != set(world_source):
|
||||
raise SessionIntegrityError("E23 fusion and world timelines differ")
|
||||
fusion_rows: list[dict[str, Any]] = []
|
||||
world_rows: list[dict[str, Any]] = []
|
||||
dropped_indices: list[int] = []
|
||||
for index in range(frame_count):
|
||||
session_seconds = float(frame_times[index]) / 1_000_000_000
|
||||
fusion = fusion_source.get(index)
|
||||
world = world_source.get(index)
|
||||
if fusion is None or world is None:
|
||||
dropped_indices.append(index)
|
||||
fusion_rows.append(
|
||||
{
|
||||
"schema_version": "missioncore.e10-fusion-frame/v1",
|
||||
"frame_index": index,
|
||||
"source_frame_index": index,
|
||||
"session_seconds": session_seconds,
|
||||
"fusion_state": "detector-dropped-latest-wins",
|
||||
"semantic_source_frame_index": None,
|
||||
"semantic_status": "unavailable",
|
||||
"objects": [],
|
||||
}
|
||||
)
|
||||
world_rows.append(_dropped_world_row(index, session_seconds))
|
||||
continue
|
||||
normalized_fusion = json.loads(json.dumps(fusion))
|
||||
normalized_fusion.update(
|
||||
{
|
||||
"schema_version": "missioncore.e10-fusion-frame/v1",
|
||||
"frame_index": index,
|
||||
"source_frame_index": index,
|
||||
"session_seconds": session_seconds,
|
||||
}
|
||||
)
|
||||
normalized_world = json.loads(json.dumps(world))
|
||||
normalized_world.update(
|
||||
{
|
||||
"frame_index": index,
|
||||
"source_frame_index": index,
|
||||
"session_seconds": session_seconds,
|
||||
}
|
||||
)
|
||||
fusion_rows.append(normalized_fusion)
|
||||
world_rows.append(normalized_world)
|
||||
expected_drops = int(worker_report["metrics"]["detector"]["queue"]["dropped_overflow"])
|
||||
if len(dropped_indices) != expected_drops:
|
||||
raise SessionIntegrityError("E23 detector replacement accounting changed")
|
||||
|
||||
baseline = _quality_metrics(raw_worker_rows, reference_masks)
|
||||
stabilized = _quality_metrics(stable_worker_rows, stabilized_masks)
|
||||
reductions = {
|
||||
"tracking_2d_acceleration_p95_fraction": _fraction_reduction(
|
||||
baseline["tracking_2d"]["normalized_acceleration"]["p95"],
|
||||
stabilized["tracking_2d"]["normalized_acceleration"]["p95"],
|
||||
),
|
||||
"tracking_2d_size_step_p95_fraction": _fraction_reduction(
|
||||
baseline["tracking_2d"]["normalized_size_step"]["p95"],
|
||||
stabilized["tracking_2d"]["normalized_size_step"]["p95"],
|
||||
),
|
||||
"cuboid_center_step_p95_fraction": _fraction_reduction(
|
||||
baseline["cuboids_3d"]["center_step_m"]["p95"],
|
||||
stabilized["cuboids_3d"]["center_step_m"]["p95"],
|
||||
),
|
||||
"cuboid_size_step_p95_fraction": _fraction_reduction(
|
||||
baseline["cuboids_3d"]["half_size_step_m"]["p95"],
|
||||
stabilized["cuboids_3d"]["half_size_step_m"]["p95"],
|
||||
),
|
||||
"cuboid_yaw_step_p95_fraction": _fraction_reduction(
|
||||
baseline["cuboids_3d"]["yaw_step_degrees"]["p95"],
|
||||
stabilized["cuboids_3d"]["yaw_step_degrees"]["p95"],
|
||||
),
|
||||
"semantic_unsupported_change_fraction": float(
|
||||
worker_report["metrics"]["temporal_stability"]["semantic"][
|
||||
"unsupported_change_reduction_fraction"
|
||||
]
|
||||
),
|
||||
}
|
||||
temporal = worker_report["metrics"]["temporal_stability"]
|
||||
acceptance = profile["acceptance"]
|
||||
quality_checks = {
|
||||
"worker_runtime_accepted": worker_report["state"] == "accepted"
|
||||
and all(worker_report["acceptance"]["checks"].values()),
|
||||
"source_is_complete_1x": source_report["state"] == "completed"
|
||||
and source_report["source"]["speed"] == 1.0,
|
||||
"minimum_2d_acceleration_reduction": reductions["tracking_2d_acceleration_p95_fraction"]
|
||||
>= float(acceptance["minimum_2d_acceleration_p95_reduction_fraction"]),
|
||||
"minimum_3d_center_reduction": reductions["cuboid_center_step_p95_fraction"]
|
||||
>= float(acceptance["minimum_3d_center_step_p95_reduction_fraction"]),
|
||||
"minimum_3d_yaw_reduction": reductions["cuboid_yaw_step_p95_fraction"]
|
||||
>= float(acceptance["minimum_3d_yaw_step_p95_reduction_fraction"]),
|
||||
"minimum_semantic_unsupported_change_reduction": reductions[
|
||||
"semantic_unsupported_change_fraction"
|
||||
]
|
||||
>= float(acceptance["minimum_semantic_unsupported_change_reduction_fraction"]),
|
||||
"maximum_camera_frame_processing_p95": float(
|
||||
worker_report["metrics"]["latency_ms"]["temporal_2d_3d_ms"]["p95"]
|
||||
)
|
||||
<= float(acceptance["maximum_camera_frame_processing_p95_ms"]),
|
||||
"maximum_semantic_frame_processing_p95": float(temporal["semantic"]["processing_ms"]["p95"])
|
||||
<= float(acceptance["maximum_semantic_frame_processing_p95_ms"]),
|
||||
"maximum_track_states": int(temporal["tracking_2d_3d"]["peak_track_states"])
|
||||
<= int(acceptance["maximum_track_states_observed"]),
|
||||
"maximum_rss_growth": float(worker_report["metrics"]["runtime_telemetry"]["rss_growth_mib"])
|
||||
<= float(acceptance["maximum_rss_growth_mib"]),
|
||||
}
|
||||
quality = {
|
||||
"schema_version": "missioncore.e23-inline-quality/v1",
|
||||
"baseline": baseline,
|
||||
"stabilized": stabilized,
|
||||
"reductions": reductions,
|
||||
"checks": quality_checks,
|
||||
}
|
||||
if not all(quality_checks.values()):
|
||||
failed = [name for name, accepted in quality_checks.items() if not accepted]
|
||||
raise SessionIntegrityError(f"E23 inline temporal quality failed: {', '.join(failed)}")
|
||||
|
||||
box_offsets = [0]
|
||||
centers: list[list[float]] = []
|
||||
half_sizes: list[list[float]] = []
|
||||
quaternions: list[list[float]] = []
|
||||
colors: list[list[int]] = []
|
||||
for row in fusion_rows:
|
||||
for item in row["objects"]:
|
||||
if not str(item.get("cuboid_status", "")).startswith("accepted-"):
|
||||
continue
|
||||
centers.append(item["cuboid_center_map"])
|
||||
half_sizes.append(item["cuboid_half_size"])
|
||||
quaternions.append(item["cuboid_quaternion_xyzw"])
|
||||
colors.append(_cuboid_color(item))
|
||||
box_offsets.append(len(centers))
|
||||
|
||||
worker_identity = worker_document["identity"]
|
||||
configuration = {
|
||||
"pipeline": "e23-inline-temporal-envelope-visual-projection/v1",
|
||||
"profile_sha256": profile_sha256,
|
||||
"profile": profile,
|
||||
"worker_result_id": worker_document["result_id"],
|
||||
"source_report": {
|
||||
"schema_version": source_report["schema_version"],
|
||||
"session_id": source_report["session_id"],
|
||||
"speed": source_report["source"]["speed"],
|
||||
},
|
||||
"semantic_mask_materialization": {
|
||||
"mode": "inline-reconstruction-from-immutable-reference-exact-sha256",
|
||||
"reference_result_id": reference.result_id,
|
||||
"matched_masks": len(semantic_rows),
|
||||
},
|
||||
"quality": quality,
|
||||
}
|
||||
selection = {
|
||||
"frame_count": frame_count,
|
||||
"source_start_frame_index": 0,
|
||||
"source_end_frame_index": frame_count - 1,
|
||||
"timeline_start_seconds": float(frame_times[0]) / 1_000_000_000,
|
||||
"timeline_end_seconds": float(frame_times[-1]) / 1_000_000_000,
|
||||
"timeline_sha256": hashlib.sha256(frame_times.tobytes()).hexdigest(),
|
||||
}
|
||||
identity = {
|
||||
"schema_version": "missioncore.e10-integrated-perception-identity/v1",
|
||||
"job_id": lab_job.job_id,
|
||||
"input_sha256": lab_job.input_sha256,
|
||||
"session_id": lab_session_id,
|
||||
"source_id": lab_job.source_id,
|
||||
"lidar_pack_id": lab_pack.name,
|
||||
"selection": selection,
|
||||
"configuration": configuration,
|
||||
"models": worker_identity["models"],
|
||||
}
|
||||
identity_sha256 = hashlib.sha256(_canonical_json(identity)).hexdigest()
|
||||
result_id = f"e10-integrated-perception-{identity_sha256}"
|
||||
destination = results_root / result_id
|
||||
if destination.exists():
|
||||
existing = _read_object(destination / "result.json", destination)
|
||||
if existing.get("identity") != identity:
|
||||
raise SessionIntegrityError("E23 LAB visual result id collides")
|
||||
return destination, quality
|
||||
|
||||
staging = _staging_directory(results_root, result_id)
|
||||
try:
|
||||
semantic_path = staging / "semantic-frames.jsonl"
|
||||
fusion_path = staging / "fusion-frames.jsonl"
|
||||
world_path = staging / "world-state.jsonl"
|
||||
arrays_path = staging / "transient-perception.npz"
|
||||
gpu_path = staging / "gpu-telemetry.jsonl"
|
||||
report_path = staging / "run-report.json"
|
||||
_write_jsonl(semantic_path, semantic_rows)
|
||||
_write_jsonl(fusion_path, fusion_rows)
|
||||
_write_jsonl(world_path, world_rows)
|
||||
np.savez_compressed(
|
||||
arrays_path,
|
||||
frame_times_ns=frame_times.astype(np.int64, copy=False),
|
||||
semantic_frame_indices=reference_indices.astype(np.int64, copy=False),
|
||||
semantic_masks=stabilized_masks.astype(np.uint8, copy=False),
|
||||
support_offsets=np.zeros(frame_count + 1, dtype=np.int64),
|
||||
support_points=np.empty((0, 3), dtype=np.float32),
|
||||
support_colors=np.empty((0, 3), dtype=np.uint8),
|
||||
box_offsets=np.asarray(box_offsets, dtype=np.int64),
|
||||
box_centers=np.asarray(centers, dtype=np.float32).reshape((-1, 3)),
|
||||
box_half_sizes=np.asarray(half_sizes, dtype=np.float32).reshape((-1, 3)),
|
||||
box_quaternions=np.asarray(quaternions, dtype=np.float32).reshape((-1, 4)),
|
||||
box_colors=np.asarray(colors, dtype=np.uint8).reshape((-1, 4)),
|
||||
)
|
||||
shutil.copyfile(worker_root / "gpu-telemetry.jsonl", gpu_path)
|
||||
report = {
|
||||
"schema_version": "missioncore.e10-integrated-perception-report/v1",
|
||||
"result_id": result_id,
|
||||
"created_at_utc": worker_report["created_at_utc"],
|
||||
"state": "accepted",
|
||||
"ground_truth": False,
|
||||
"identity": identity,
|
||||
"acceptance": {
|
||||
"accepted": True,
|
||||
"navigation_or_safety_accepted": False,
|
||||
"checks": quality_checks,
|
||||
},
|
||||
"metrics": {
|
||||
**worker_report["metrics"],
|
||||
"quality": quality,
|
||||
"visual_projection": {
|
||||
"frames": frame_count,
|
||||
"semantic_masks": len(semantic_rows),
|
||||
"detector_replacement_frames": dropped_indices,
|
||||
"accepted_cuboids": len(centers),
|
||||
},
|
||||
},
|
||||
"runtime": worker_report.get("runtime", {}),
|
||||
"limitations": [
|
||||
"This is the accepted E23 recorded 1x inline worker gate, not a physical K1 run.",
|
||||
"Latest-wins detector replacements are explicit empty visual frames.",
|
||||
"Semantic pixels are reconstructed only after exact inline SHA-256 matches.",
|
||||
"LiDAR support points remain in the immutable source scene and are not duplicated.",
|
||||
"Navigation and safety authority remain disabled.",
|
||||
],
|
||||
}
|
||||
write_json_atomic(report_path, report)
|
||||
artifacts = [
|
||||
_artifact_descriptor(
|
||||
"e10-semantic-frames",
|
||||
semantic_path,
|
||||
"missioncore.e10-semantic-frame/v1",
|
||||
),
|
||||
_artifact_descriptor(
|
||||
"e10-fusion-frames",
|
||||
fusion_path,
|
||||
"missioncore.e10-fusion-frame/v1",
|
||||
),
|
||||
_artifact_descriptor(
|
||||
"e10-world-state",
|
||||
world_path,
|
||||
"missioncore.live-perception-world-state/v1",
|
||||
),
|
||||
_artifact_descriptor("e10-transient-perception", arrays_path, None),
|
||||
_artifact_descriptor("worker-gpu-telemetry", gpu_path, None),
|
||||
_artifact_descriptor(
|
||||
"e10-run-report",
|
||||
report_path,
|
||||
"missioncore.e10-integrated-perception-report/v1",
|
||||
),
|
||||
]
|
||||
write_json_atomic(
|
||||
staging / "result.json",
|
||||
{
|
||||
"schema_version": "missioncore.e10-integrated-perception-result/v1",
|
||||
"result_id": result_id,
|
||||
"identity_sha256": identity_sha256,
|
||||
"identity": identity,
|
||||
"created_at_utc": worker_report["created_at_utc"],
|
||||
"ground_truth": False,
|
||||
"publication_scope": "recorded-integrated-realtime-qualification-only",
|
||||
"acceptance_state": "accepted",
|
||||
"frames_processed": frame_count,
|
||||
"artifacts": artifacts,
|
||||
},
|
||||
)
|
||||
_publish_directory(staging, destination)
|
||||
finally:
|
||||
_remove_staging(staging)
|
||||
return destination, quality
|
||||
|
||||
|
||||
def _dropped_world_row(frame_index: int, session_seconds: float) -> dict[str, Any]:
|
||||
return {
|
||||
"schema_version": "missioncore.live-perception-world-state/v1",
|
||||
@@ -799,6 +1316,13 @@ def _cuboid_color(item: dict[str, Any]) -> list[int]:
|
||||
return [64 + digest[0] % 176, 64 + digest[1] % 176, 64 + digest[2] % 176, 88]
|
||||
|
||||
|
||||
def _fraction_reduction(baseline: int | float, stabilized: int | float) -> float:
|
||||
baseline_value = float(baseline)
|
||||
if baseline_value <= 0:
|
||||
return 0.0
|
||||
return (baseline_value - float(stabilized)) / baseline_value
|
||||
|
||||
|
||||
def _read_jsonl(path: Path) -> list[dict[str, Any]]:
|
||||
rows: list[dict[str, Any]] = []
|
||||
with path.open(encoding="utf-8") as stream:
|
||||
|
||||
Reference in New Issue
Block a user