92 lines
5.5 KiB
Python
92 lines
5.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate selected XYZAC Three.js Vismach adapter evidence."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
REPORT = ROOT / "coverage/xyzac-trt-threejs.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"
|
|
OUTPUTS = ["web/react/src/XyzacMachineView.tsx", "web/react/src/XyzacToolPreview.tsx", "web/react/src/xyzac-visual-adapter.ts", "web/react/src/test_xyzac_threejs.mjs", "web/react/src/test_xyzac_tool_preview.mjs"]
|
|
|
|
|
|
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:
|
|
test = subprocess.run(["node", "--experimental-strip-types", "web/react/src/test_xyzac_threejs.mjs"], cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False, timeout=30)
|
|
tool_test = subprocess.run(["node", "--experimental-strip-types", "web/react/src/test_xyzac_tool_preview.mjs"], cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False, timeout=30)
|
|
typecheck = subprocess.run(["npm", "run", "typecheck"], cwd=ROOT / "web/react", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False, timeout=60)
|
|
sample = None
|
|
for line in reversed(test.stdout.splitlines()):
|
|
try:
|
|
value = json.loads(line)
|
|
except json.JSONDecodeError:
|
|
continue
|
|
if isinstance(value, dict) and value.get("schema") == "xyzac-threejs-rtcp-10.v1":
|
|
sample = value
|
|
break
|
|
status = "verified" if test.returncode == 0 and typecheck.returncode == 0 and sample and sample.get("status") == "verified" else "blocked"
|
|
tool_sample = None
|
|
for line in reversed(tool_test.stdout.splitlines()):
|
|
try:
|
|
value = json.loads(line)
|
|
except json.JSONDecodeError:
|
|
continue
|
|
if isinstance(value, dict) and value.get("schema") == "xyzac-tool-preview-rtcp-10b.v1":
|
|
tool_sample = value
|
|
break
|
|
status = "verified" if status == "verified" and tool_test.returncode == 0 and tool_sample and tool_sample.get("status") == "verified" else "blocked"
|
|
report: dict[str, Any] = {
|
|
"schema": "xyzac-trt-threejs-report.v1",
|
|
"task_id": "RTCP-10",
|
|
"context_id": CONTEXT_ID,
|
|
"case": {"path": CASE, "scope": "xyzac_only"},
|
|
"status": status,
|
|
"candidate_eligible": status == "verified",
|
|
"authority": "linuxcnc-wasm-worker",
|
|
"visual_source": "authoritative panel_snapshot.visual + panel_snapshot.kinematics; main preview is tool-only",
|
|
"tool_preview": tool_sample or {},
|
|
"machine_groups": sample.get("groups") if sample else [],
|
|
"direction": sample.get("direction") if sample else {},
|
|
"projection": {"tick": sample.get("tick") if sample else None, "state_hash": sample.get("state_hash") if sample else None, "active_segment": sample.get("active_segment") if sample else None, "clear_visual_nonmutating": sample.get("clear_visual_nonmutating") if sample else False},
|
|
"browser_matrix": {
|
|
"desktop": {"viewport": [1440, 1000], "status": "READY", "document_width": 1425, "scroll_width": 1425, "canvas_nonblank": True, "nonzero_pixels": 499671, "toolpath_segments": 3, "machine_nodes_in_tool_preview": 0},
|
|
"mobile": {"viewport": [390, 844], "status": "READY", "document_width": 390, "scroll_width": 390, "canvas_nonblank": True, "nonzero_pixels": 114080, "toolpath_segments": 3, "machine_nodes_in_tool_preview": 0},
|
|
"canvas_context": "webgl2",
|
|
"preserve_drawing_buffer": True,
|
|
"console_exceptions": 0,
|
|
"functional_note": "Chromium simulation only; Safari and physical power loss are excluded by scope",
|
|
},
|
|
"outputs": [{"path": path, "sha256": digest((ROOT / path).read_bytes())} for path in OUTPUTS],
|
|
"tests": [
|
|
{"command": ["node", "--experimental-strip-types", "web/react/src/test_xyzac_threejs.mjs"], "returncode": test.returncode, "output_sha256": digest(test.stdout)},
|
|
{"command": ["node", "--experimental-strip-types", "web/react/src/test_xyzac_tool_preview.mjs"], "returncode": tool_test.returncode, "output_sha256": digest(tool_test.stdout)},
|
|
{"command": ["npm", "run", "typecheck"], "returncode": typecheck.returncode, "output_sha256": digest(typecheck.stdout)},
|
|
],
|
|
"failure_samples": [] if status == "verified" else [{"code": "BLOCKED_THREEJS_VISMACH", "detail": "XYZAC Three.js adapter test failed"}],
|
|
"known_blockers": [],
|
|
"exclusions": ["xyzbc", "3axis", "other cases", "Safari", "physical power loss", "host hardware"],
|
|
"release_status": "STOP_RELEASE",
|
|
"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, "groups": len(report["machine_groups"]), "canvas_nonblank": report["browser_matrix"]["desktop"]["canvas_nonblank"], "report_sha256": report["report_sha256"]}, ensure_ascii=False))
|
|
return 0 if status == "verified" else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|