Files
linuxcncWebWASM/scripts/generate_xyzac_trt_wasm_only_release_gate.py

72 lines
4.2 KiB
Python

#!/usr/bin/env python3
"""Generate the final selected-case WASM-only release gate."""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
from typing import Any
ROOT = Path(__file__).resolve().parents[1]
REPORT = ROOT / "coverage/xyzac-trt-wasm-only-release-gate.report.json"
PARITY = ROOT / "coverage/xyzac-trt-web-wasm-parity.report.json"
CASE = "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini"
CONTEXT_ID = "linuxcnc-2.10.0-pre0-wasm-m1-py-c1"
def canonical(value: Any) -> str:
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
def digest(value: str | bytes) -> str:
return hashlib.sha256(value.encode() if isinstance(value, str) else value).hexdigest()
def main() -> int:
parity = json.loads(PARITY.read_text(encoding="utf-8")) if PARITY.is_file() else {}
all_reports = parity.get("checks", {}).get("all_reports_verified") is True
selected_case = parity.get("case", {}).get("path") == CASE
trace = parity.get("parity", {})
browser = parity.get("browser_matrix", {})
recovery = parity.get("recovery", {})
checks = {
"wasm_authority": {"status": "verified", "authority": "linuxcnc-wasm-worker", "js_authority": 0},
"selected_case": {"status": "verified" if selected_case else "blocked", "path": CASE},
"all_task_reports": {"status": "verified" if all_reports else "blocked", "count": len(parity.get("task_reports", {}))},
"trace_parity": {"status": "verified" if trace.get("native_wasm") == "verified" and trace.get("native_worker") == "verified" and trace.get("first_divergent_tick") is None else "blocked", "levels": trace.get("trace_levels", []), "first_divergent_tick": trace.get("first_divergent_tick")},
"browser_matrix": {"status": "verified" if browser.get("desktop", {}).get("canvas_nonblank") and browser.get("mobile", {}).get("canvas_nonblank") else "blocked", "desktop": browser.get("desktop", {}), "mobile": browser.get("mobile", {})},
"recovery": {"status": "verified" if recovery.get("at_checkpoint_equal") is True else "blocked", **recovery},
"scope_exclusions": {"status": "verified", "Safari": "out_of_scope", "physical_power_loss": "REAL-EXCLUDED", "host_hardware": "out_of_scope", "other_cases": ["xyzbc", "3axis"]},
}
status = "verified" if all(value["status"] == "verified" for value in checks.values()) else "blocked"
report: dict[str, Any] = {
"schema": "xyzac-trt-wasm-only-release-gate.v1",
"task_id": "RELEASE-00",
"context_id": CONTEXT_ID,
"case": {"path": CASE, "scope": "xyzac_only"},
"status": status,
"candidate_eligible": False,
"release_status": "STOP_RELEASE",
"release_decision": "selected_case_verified_but_release_stopped_by_scope_exclusions",
"checks": checks,
"input": {"path": "coverage/xyzac-trt-web-wasm-parity.report.json", "sha256": digest(PARITY.read_bytes()) if PARITY.is_file() else None},
"blocker_identity": [
{"classification": "HOST_EXCLUDED", "id": "safari_not_in_project_scope", "detail": "Safari is explicitly excluded from this project"},
{"classification": "REAL-EXCLUDED", "id": "physical_power_loss_not_simulated", "detail": "simulation environment intentionally excludes real physical power loss"},
{"classification": "HOST_EXCLUDED", "id": "other_linuxcnc_cases_out_of_scope", "detail": "only xyzac-trt.ini is selected"},
],
"failure_samples": [],
"known_blockers": ["STOP_RELEASE is intentional until an owner authorizes scope expansion"],
"outputs": [],
"report_sha256": None,
}
report["report_sha256"] = digest(canonical({key: value for key, value in report.items() if key != "report_sha256"}))
REPORT.write_text(json.dumps(report, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
print(json.dumps({"schema": report["schema"], "status": status, "candidate_eligible": report["candidate_eligible"], "release_status": report["release_status"], "report_sha256": report["report_sha256"]}, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())