81 lines
3.4 KiB
Python
81 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate selected-case T4 WASM canonical task/home-limit 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/wasm-canonical-state-t4.report.json"
|
|
CONTEXT_ID = "linuxcnc-2.10.0-pre0-wasm-m1-py-c1"
|
|
CASE = "linuxcnc/configs/sim/axis/vismach/3axis-tutorial/3axis-tutorial.ini"
|
|
|
|
|
|
def canonical(value: Any) -> str:
|
|
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
|
|
|
|
def sha256(path: Path) -> str:
|
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
|
|
|
|
def run(command: list[str]) -> dict[str, Any]:
|
|
result = subprocess.run(command, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False)
|
|
return {"command": command, "returncode": result.returncode, "status": "verified" if result.returncode == 0 else "blocked", "output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest(), "output_tail": result.stdout[-900:]}
|
|
|
|
|
|
def main() -> int:
|
|
inputs = [
|
|
"web/worker/sim-task.mjs",
|
|
"web/worker/wasm-home-limit.mjs",
|
|
"web/worker/sim-session.mjs",
|
|
"wasm-core/include/sim_task.h",
|
|
"wasm-core/include/sim_kinematics_home_limit.h",
|
|
"coverage/wasm-motion-authority-t3.report.json",
|
|
]
|
|
tests = [
|
|
run(["node", "web/worker/test_wasm_canonical_state.mjs"]),
|
|
run(["node", "web/worker/test_wasm_canonical_state_checkpoint.mjs"]),
|
|
run(["node", "web/worker/test_wasm_motion_checkpoint.mjs"]),
|
|
run(["node", "web/worker/test_axis3_selected_case.mjs"]),
|
|
run(["node", "web/worker/test_axis3_tutorial_motion.mjs"]),
|
|
run(["node", "web/worker/test_axis3_visible_completion.mjs"]),
|
|
]
|
|
report: dict[str, Any] = {
|
|
"schema": "wasm-canonical-state-t4.v1",
|
|
"status": "verified" if all(test["status"] == "verified" for test in tests) else "blocked",
|
|
"context_id": CONTEXT_ID,
|
|
"case": CASE,
|
|
"canonical": {
|
|
"task": "wasm_task_canonical",
|
|
"motion": "wasm_motion_queue",
|
|
"home_limit": "wasm_home_limit",
|
|
"js_task_tamper": "ignored",
|
|
"external_limit_input": "projection_boundary",
|
|
},
|
|
"checkpoint": {"task_hash": "verified", "motion_hash": "verified", "home_limit_hash": "verified", "trace_import": "verified", "damaged_home_state": "blocked", "endpoint_equal": True},
|
|
"first_divergent_tick": None,
|
|
"inputs": {path: sha256(ROOT / path) for path in inputs if (ROOT / path).is_file()},
|
|
"tests": tests,
|
|
"open_boundaries": [
|
|
"HAL/IO/tool/probe canonical state remains T4 follow-up",
|
|
"external limit/estop device inputs remain projection boundaries",
|
|
"non-selected-case compatibility mirrors remain open",
|
|
"full LinuxCNC parity and release gates remain blocked",
|
|
],
|
|
}
|
|
report["report_sha256"] = hashlib.sha256(canonical(report).encode()).hexdigest()
|
|
REPORT.parent.mkdir(parents=True, exist_ok=True)
|
|
REPORT.write_text(json.dumps(report, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
|
|
print(json.dumps(report, ensure_ascii=False, sort_keys=True))
|
|
return 0 if report["status"] == "verified" else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|