feat(laboratory): publish M48S load envelope

This commit is contained in:
DCCONSTRUCTIONS
2026-08-25 20:36:26 +03:00
parent e21332b9e1
commit bab0bb2df2
8 changed files with 624 additions and 23 deletions
@@ -22,6 +22,7 @@ CATALOG_SCHEMA: Final = "missioncore.m48s-fixed-class-detector-frame-catalog/v1"
FRAME_SCHEMA: Final = "missioncore.m48s-fixed-class-detector-frame/v1"
REPORT_SCHEMA: Final = "missioncore.m48s-fixed-class-detector-report/v1"
RUNTIME_HARDENING_SCHEMA: Final = "missioncore.m48s-runtime-hardening-comparison/v1"
LOAD_ENVELOPE_SCHEMA: Final = "missioncore.m48s-load-envelope-comparison/v1"
METHOD_SCHEMA: Final = "missioncore.laboratory-method/v1"
RESULT_PREFIX: Final = "m48s-fixed-class-detector-lab-"
TOURNAMENT_ID: Final = (
@@ -65,6 +66,47 @@ RUNTIME_HARDENING_RUNS: Final = {
"frame_count": 1000,
},
}
LOAD_ENVELOPE_RUNS: Final = {
"production-10fps": {
"run_id": "m48s-load-envelope-v1-production-10fps-a1",
"load_purpose": "production-rate",
"source_rate_hz": 10.0,
"result_sha256": "60d4d82a8d47e5087019640353c9f8f7ddae518b52801dfd8c64423f5aba9fe2",
"frames_sha256": "9e836f13a49390be498ce2b133fe2c20538af43adf667b0e7b89dc6349379ab0",
"delivered": 4483,
"superseded": 6,
"operating_target_gate_passed": False,
},
"reserve-12fps": {
"run_id": "m48s-load-envelope-v1-reserve-12fps-a1",
"load_purpose": "reserve-gate",
"source_rate_hz": 12.0,
"result_sha256": "c8cb917f6f3a8cb6ffcc5146211066dbaed4aa2d8671e55820c266c49d5d5321",
"frames_sha256": "3c1e635f6fbea643024bbd1711fb6c1ed5380430972cbb434ec76f4488d1c8b7",
"delivered": 4477,
"superseded": 12,
"operating_target_gate_passed": True,
},
"limit-15fps": {
"run_id": "m48s-load-envelope-v1-limit-15fps-a1",
"load_purpose": "limit-discovery",
"source_rate_hz": 15.0,
"result_sha256": "a78767ee2a7d8f3f7f7625c408e9bc8fb6c60e8ba6f77ab54fddbca018540713",
"frames_sha256": "8be16ed155111ffa7093bbf46ceda4bc679593bfaf7a00c38c5d50c2385138d0",
"delivered": 4488,
"superseded": 1,
"operating_target_gate_passed": True,
},
}
LOAD_ENVELOPE_PROFILE_SHA256: Final = (
"d63c711534d84ee526d056885cfa0b5221df61d8394b244188b735bb34d20869"
)
LOAD_RUNTIME_ARTIFACT_SHA256: Final = (
"c2344c91ce48111abb364cad38bd73fca9e5b30c8d001c113718dc1b30a8d859"
)
LOAD_RUNNER_SHA256: Final = (
"0ff2ed9bdf5d5982cce08c4930853f65aa7be2c5986afacfe6a7cf925a2815e9"
)
YOLOX_ID: Final = (
"m48s-yolox-all-coco-shadow-7dbe6043b3fc12c7ddb162f609f883d86b34a4f2dd3785a632795f257e192d06"
)
@@ -149,6 +191,11 @@ def build_m48s_fixed_class_detector_lab(
}
for name, definition in RUNTIME_HARDENING_RUNS.items()
}
load_envelope_profile_path = repository / "config/perception/m48s-load-envelope-v1.json"
load_envelope_paths = {
name: runtime / "load-envelope-worker" / str(definition["run_id"]) / "result.json"
for name, definition in LOAD_ENVELOPE_RUNS.items()
}
yolox_root = runtime / "yolox-all-coco-results" / YOLOX_ID
yolox_manifest_path = yolox_root / "manifest.json"
yolox_frames_path = yolox_root / "frames.jsonl"
@@ -171,6 +218,8 @@ def build_m48s_fixed_class_detector_lab(
dfine_path,
rf_detr_path,
profile_path,
load_envelope_profile_path,
*load_envelope_paths.values(),
*(path for paths in hardening_paths.values() for path in paths.values()),
):
if path.is_symlink() or not path.is_file():
@@ -188,6 +237,10 @@ def build_m48s_fixed_class_detector_lab(
hardening_runs = {
name: _read_object(paths["result"]) for name, paths in hardening_paths.items()
}
load_envelope_profile = _read_object(load_envelope_profile_path)
load_envelope_runs = {
name: _read_object(path) for name, path in load_envelope_paths.items()
}
hardening_first_frames = {
name: _read_first_jsonl_object(paths["frames"])
for name, paths in hardening_paths.items()
@@ -215,6 +268,10 @@ def build_m48s_fixed_class_detector_lab(
hardening_runs=hardening_runs,
hardening_first_frames=hardening_first_frames,
hardening_paths=hardening_paths,
load_envelope_profile=load_envelope_profile,
load_envelope_profile_path=load_envelope_profile_path,
load_envelope_runs=load_envelope_runs,
load_envelope_paths=load_envelope_paths,
)
source_paths = {frame_id: source_root / f"frame-{frame_id}.jpg" for frame_id in FRAME_IDS}
@@ -277,6 +334,16 @@ def build_m48s_fixed_class_detector_lab(
}
for name, paths in hardening_paths.items()
},
"load_envelope": {
"profile_sha256": sha256_path(load_envelope_profile_path),
"runs": {
name: {
"result_sha256": sha256_path(load_envelope_paths[name]),
"frames_sha256": run["execution"]["frame_evidence"]["sha256"],
}
for name, run in load_envelope_runs.items()
},
},
"yolox_result_id": YOLOX_ID,
"yolox_document_sha256": sha256_path(yolox_manifest_path),
},
@@ -285,7 +352,7 @@ def build_m48s_fixed_class_detector_lab(
}
identity_sha256 = hashlib.sha256(canonical_json(identity)).hexdigest()
result_id = RESULT_PREFIX + identity_sha256
completed_utc_ns = hardening_runs["prewarmed"].get("completed_utc_ns")
completed_utc_ns = load_envelope_runs["limit-15fps"].get("completed_utc_ns")
if not isinstance(completed_utc_ns, int) or isinstance(completed_utc_ns, bool):
raise M48SFixedClassDetectorLabError(
"complete reference-graph completion time is unavailable"
@@ -309,6 +376,7 @@ def build_m48s_fixed_class_detector_lab(
candidates=candidates,
hardening_runs=hardening_runs,
hardening_first_frames=hardening_first_frames,
load_envelope_runs=load_envelope_runs,
)
decision = {
"bounded_question_accepted": True,
@@ -317,6 +385,11 @@ def build_m48s_fixed_class_detector_lab(
"integrated_world_state_gate_evaluated": True,
"integrated_world_state_gate_passed": True,
"full_replay_visual_published": True,
"load_envelope_evaluated": True,
"production_rate_repeatability_passed": False,
"reserve_12_fps_passed": True,
"limit_15_fps_passed": True,
"load_envelope_accepted": False,
"detector_replacement_authorized": False,
"production_accepted": False,
}
@@ -335,6 +408,11 @@ def build_m48s_fixed_class_detector_lab(
"The visual timeline is the original qualified semantic replay; runtime-hardening "
"metrics come from separately sealed, input-identical replay runs."
),
(
"The 12 and 15 FPS operating gates passed, but the separately predeclared 10 FPS "
"delivery-ratio gate missed by two frames; capacity is demonstrated while delivery "
"repeatability remains open."
),
]
root = output_root.expanduser().absolute()
@@ -421,6 +499,12 @@ def build_m48s_fixed_class_detector_lab(
)
for name, paths in hardening_paths.items():
shutil.copyfile(paths["result"], temporary / f"runtime-hardening-{name}.json")
shutil.copyfile(
load_envelope_profile_path,
temporary / "runtime-load-envelope-profile.json",
)
for name, path in load_envelope_paths.items():
shutil.copyfile(path, temporary / f"runtime-load-{name}.json")
startup_evidence = {
"schema_version": RUNTIME_HARDENING_SCHEMA,
"source_frames_sha256": {
@@ -441,11 +525,15 @@ def build_m48s_fixed_class_detector_lab(
"detector_load": load["execution"],
"complete_reference_graph": reference_graph["identity"]["evidence"]["execution"],
"runtime_hardening": metrics["runtime_hardening"],
"load_envelope": metrics["load_envelope"],
},
"metrics": metrics,
"acceptance": {
"detector_load": load["checks"],
"complete_reference_graph": reference_graph["identity"]["evidence"]["checks"],
"load_envelope": {
name: run["checks"] for name, run in load_envelope_runs.items()
},
},
"decision": decision,
"limitations": limitations,
@@ -515,6 +603,10 @@ def _validate_inputs(
hardening_runs: dict[str, dict[str, Any]],
hardening_first_frames: dict[str, dict[str, Any]],
hardening_paths: dict[str, dict[str, Path]],
load_envelope_profile: dict[str, Any],
load_envelope_profile_path: Path,
load_envelope_runs: dict[str, dict[str, Any]],
load_envelope_paths: dict[str, Path],
) -> None:
decision = deployment.get("decision")
graph_identity = reference_graph.get("identity")
@@ -654,6 +746,101 @@ def _validate_inputs(
raise M48SFixedClassDetectorLabError(
f"runtime-hardening startup evidence changed: {name}"
)
_validate_load_envelope(
profile=load_envelope_profile,
profile_path=load_envelope_profile_path,
runs=load_envelope_runs,
paths=load_envelope_paths,
)
def _validate_load_envelope(
*,
profile: dict[str, Any],
profile_path: Path,
runs: dict[str, dict[str, Any]],
paths: dict[str, Path],
) -> None:
scenarios = profile.get("scenarios")
if (
profile.get("schema_version") != "missioncore.m48s-load-envelope-profile/v1"
or profile.get("profile_id") != "m48s-rf-detr-reference-graph-load-envelope/v1"
or sha256_path(profile_path) != LOAD_ENVELOPE_PROFILE_SHA256
or not isinstance(scenarios, list)
or len(scenarios) != len(LOAD_ENVELOPE_RUNS)
):
raise M48SFixedClassDetectorLabError("load-envelope profile identity changed")
scenarios_by_id = {
scenario.get("id"): scenario for scenario in scenarios if isinstance(scenario, dict)
}
if set(scenarios_by_id) != set(LOAD_ENVELOPE_RUNS):
raise M48SFixedClassDetectorLabError("load-envelope scenarios changed")
shared_inputs: dict[str, object] | None = None
for name, definition in LOAD_ENVELOPE_RUNS.items():
run = runs.get(name)
path = paths.get(name)
scenario = scenarios_by_id[name]
if not isinstance(run, dict) or not isinstance(path, Path):
raise M48SFixedClassDetectorLabError("load-envelope evidence is incomplete")
source = run.get("source")
identity = run.get("identity")
execution = run.get("execution")
integrity_checks = run.get("integrity_checks")
thresholds = run.get("predeclared_thresholds")
frame_evidence = execution.get("frame_evidence") if isinstance(execution, dict) else None
terminal = execution.get("terminal_outcomes") if isinstance(execution, dict) else None
pipeline = run.get("metrics", {}).get("pipeline_timing")
if (
run.get("schema_version") != "missioncore.m48s-reference-graph-shadow-load/v4"
or run.get("completed") is not True
or run.get("production_accepted") is not False
or run.get("authority") != false_authority()
or run.get("evidence_integrity_gate_passed") is not True
or run.get("operating_target_gate_passed")
is not definition["operating_target_gate_passed"]
or not isinstance(integrity_checks, dict)
or not integrity_checks
or not all(value is True for value in integrity_checks.values())
or not isinstance(source, dict)
or source.get("source_id") != "RAVNOVES00"
or source.get("pacing_contract")
!= "wall-clock-scaled-source-timestamps-immutable/v1"
or source.get("requested_rate_hz") != definition["source_rate_hz"]
or not isinstance(identity, dict)
or identity.get("worker_id") != "worker-006"
or identity.get("graph_id") != "reference-perception-graph/v2"
or identity.get("detector_provider_id")
!= "triton-rf-detr-large-coco-risk-fp16-shadow/v0"
or identity.get("runtime_artifact_sha256") != LOAD_RUNTIME_ARTIFACT_SHA256
or identity.get("runner_sha256") != LOAD_RUNNER_SHA256
or not isinstance(execution, dict)
or execution.get("load_purpose") != definition["load_purpose"]
or execution.get("requested_source_rate_hz") != definition["source_rate_hz"]
or execution.get("source_timestamps_preserved") is not True
or execution.get("admitted_frames") != 4489
or execution.get("delivered_world_states") != definition["delivered"]
or not isinstance(terminal, dict)
or terminal.get("delivered") != definition["delivered"]
or terminal.get("superseded") != definition["superseded"]
or sum(terminal.values()) != 4489
or not isinstance(frame_evidence, dict)
or frame_evidence.get("row_count") != definition["delivered"]
or frame_evidence.get("sha256") != definition["frames_sha256"]
or not isinstance(pipeline, dict)
or pipeline.get("additional_inference_passes") != 0
or thresholds != scenario.get("thresholds")
or sha256_path(path) != definition["result_sha256"]
):
raise M48SFixedClassDetectorLabError(
f"sealed load-envelope evidence changed: {name}"
)
inputs = identity.get("inputs")
if not isinstance(inputs, dict):
raise M48SFixedClassDetectorLabError("load-envelope input identity is unavailable")
if shared_inputs is None:
shared_inputs = inputs
elif inputs != shared_inputs:
raise M48SFixedClassDetectorLabError("load-envelope runs changed graph inputs")
def _method(
@@ -791,6 +978,7 @@ def _metrics(
candidates: list[dict[str, object]],
hardening_runs: dict[str, dict[str, Any]],
hardening_first_frames: dict[str, dict[str, Any]],
load_envelope_runs: dict[str, dict[str, Any]],
) -> dict[str, object]:
graph_evidence = reference_graph["identity"]["evidence"]
graph_execution = graph_evidence["execution"]
@@ -860,6 +1048,62 @@ def _metrics(
runs=hardening_runs,
first_frames=hardening_first_frames,
),
"load_envelope": _load_envelope_metrics(load_envelope_runs),
}
def _load_envelope_metrics(runs: dict[str, dict[str, Any]]) -> dict[str, object]:
scenarios: list[dict[str, object]] = []
for name in LOAD_ENVELOPE_RUNS:
run = runs[name]
execution = run["execution"]
metrics = run["metrics"]
completion = metrics["world_state_completion_age_ms"]
gpu = metrics["gpu"]
pipeline = metrics["pipeline_timing"]
terminal = execution["terminal_outcomes"]
thresholds = run["predeclared_thresholds"]
scenarios.append(
{
"id": name,
"load_purpose": execution["load_purpose"],
"requested_source_rate_hz": execution["requested_source_rate_hz"],
"source_frames_admitted": execution["admitted_frames"],
"delivered_world_states": execution["delivered_world_states"],
"superseded_frames": terminal.get("superseded", 0),
"delivery_ratio": execution["delivery_ratio"],
"effective_world_state_fps": execution["effective_world_state_fps"],
"world_state_completion_age_p95_ms": completion["p95"],
"world_state_completion_age_p99_ms": completion["p99"],
"world_state_completion_age_maximum_ms": completion["maximum"],
"decode_p95_ms": pipeline["decode_duration_ms"]["p95"],
"decode_maximum_ms": pipeline["decode_duration_ms"]["maximum"],
"detector_p95_ms": pipeline["detector_ms"]["total"]["p95"],
"detector_maximum_ms": pipeline["detector_ms"]["total"]["maximum"],
"gpu_utilization_mean_percent": gpu["gpu_utilization_percent"]["mean"],
"gpu_utilization_maximum_percent": gpu["gpu_utilization_percent"]["maximum"],
"gpu_memory_maximum_mib": gpu["gpu_memory_used_mib"]["maximum"],
"process_peak_rss_mib": metrics["process_peak_rss_after_mib"],
"queue_high_watermarks": execution["queue_high_watermarks"],
"queue_capacity": 2,
"additional_inference_passes": pipeline["additional_inference_passes"],
"integrity_gate_passed": run["evidence_integrity_gate_passed"],
"operating_target_gate_passed": run["operating_target_gate_passed"],
"thresholds": thresholds,
"frame_evidence_sha256": execution["frame_evidence"]["sha256"],
}
)
return {
"schema_version": LOAD_ENVELOPE_SCHEMA,
"production_rate_repeatability_passed": False,
"reserve_12_fps_passed": True,
"limit_15_fps_passed": True,
"load_envelope_accepted": False,
"compute_capacity_at_least_fps": 15.0,
"bottleneck_interpretation": (
"rare-source-decode-or-scheduling-tail-not-steady-gpu-saturation"
),
"scenarios": scenarios,
}
@@ -1016,6 +1260,12 @@ def _artifact_manifest(root: Path) -> list[dict[str, object]]:
RUNTIME_HARDENING_SCHEMA if relative == "runtime-hardening-startup.json" else None
)
role = "upstream-runtime-hardening-evidence"
elif relative == "runtime-load-envelope-profile.json":
schema_version = "missioncore.m48s-load-envelope-profile/v1"
role = "predeclared-load-envelope-profile"
elif relative.startswith("runtime-load-"):
schema_version = "missioncore.m48s-reference-graph-shadow-load/v4"
role = "upstream-load-envelope-evidence"
artifacts.append(
{
"role": role,
@@ -331,6 +331,16 @@ def _load_result_uncached(candidate: Path) -> dict[str, Any]:
or decision.get("integrated_world_state_gate_evaluated") is not integrated
or (integrated and decision.get("integrated_world_state_gate_passed") is not True)
or (integrated and decision.get("detector_replacement_authorized") is not False)
or (
metrics.get("load_envelope") is not None
and (
decision.get("load_envelope_evaluated") is not True
or decision.get("production_rate_repeatability_passed") is not False
or decision.get("reserve_12_fps_passed") is not True
or decision.get("limit_15_fps_passed") is not True
or decision.get("load_envelope_accepted") is not False
)
)
or decision.get("production_accepted") is not False
or not isinstance(method, dict)
or method.get("schema_version") != "missioncore.laboratory-method/v1"
@@ -341,6 +351,10 @@ def _load_result_uncached(candidate: Path) -> dict[str, Any]:
metrics.get("runtime_hardening") is not None
and not _valid_runtime_hardening(metrics["runtime_hardening"])
)
or (
metrics.get("load_envelope") is not None
and not _valid_load_envelope(metrics["load_envelope"])
)
or not isinstance(manifest.get("limitations"), list)
or not isinstance(catalog_descriptor, dict)
or catalog_descriptor.get("path") != "catalog.json"
@@ -420,6 +434,67 @@ def _valid_runtime_hardening(value: object) -> bool:
)
def _valid_load_envelope(value: object) -> bool:
if not isinstance(value, dict) or value.get("schema_version") != (
"missioncore.m48s-load-envelope-comparison/v1"
):
return False
if (
value.get("production_rate_repeatability_passed") is not False
or value.get("reserve_12_fps_passed") is not True
or value.get("limit_15_fps_passed") is not True
or value.get("load_envelope_accepted") is not False
or value.get("compute_capacity_at_least_fps") != 15.0
or value.get("bottleneck_interpretation")
!= "rare-source-decode-or-scheduling-tail-not-steady-gpu-saturation"
):
return False
scenarios = value.get("scenarios")
scenario_ids = [item.get("id") for item in scenarios if isinstance(item, dict)] if (
isinstance(scenarios, list)
) else []
if scenario_ids != ["production-10fps", "reserve-12fps", "limit-15fps"]:
return False
expected_targets = (False, True, True)
required_numeric = {
"requested_source_rate_hz",
"source_frames_admitted",
"delivered_world_states",
"superseded_frames",
"delivery_ratio",
"effective_world_state_fps",
"world_state_completion_age_p95_ms",
"world_state_completion_age_p99_ms",
"world_state_completion_age_maximum_ms",
"decode_p95_ms",
"decode_maximum_ms",
"detector_p95_ms",
"detector_maximum_ms",
"gpu_utilization_mean_percent",
"gpu_utilization_maximum_percent",
"gpu_memory_maximum_mib",
"process_peak_rss_mib",
"queue_capacity",
"additional_inference_passes",
}
for scenario, target in zip(scenarios, expected_targets, strict=True):
if (
not isinstance(scenario, dict)
or scenario.get("integrity_gate_passed") is not True
or scenario.get("operating_target_gate_passed") is not target
or scenario.get("additional_inference_passes") != 0
or scenario.get("queue_capacity") != 2
or not isinstance(scenario.get("queue_high_watermarks"), dict)
or any(value != 2 for value in scenario["queue_high_watermarks"].values())
or not isinstance(scenario.get("thresholds"), dict)
or any(not _nonnegative_number(scenario.get(key)) for key in required_numeric)
or not isinstance(scenario.get("frame_evidence_sha256"), str)
or SHA256.fullmatch(scenario["frame_evidence_sha256"]) is None
):
return False
return True
def _nonnegative_number(value: object) -> bool:
return isinstance(value, (int, float)) and not isinstance(value, bool) and float(value) >= 0.0