98 lines
3.7 KiB
Python
98 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate the selected-case T3 WASM motion authority 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-motion-authority-t3.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], cwd: Path = ROOT) -> dict[str, Any]:
|
|
result = subprocess.run(command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False)
|
|
return {
|
|
"command": command,
|
|
"cwd": cwd.as_posix(),
|
|
"returncode": result.returncode,
|
|
"status": "verified" if result.returncode == 0 else "blocked",
|
|
"output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest(),
|
|
"output_tail": result.stdout[-800:],
|
|
}
|
|
|
|
|
|
def main() -> int:
|
|
inputs = [
|
|
"wasm-core/include/sim_motion_queue.h",
|
|
"wasm-core/src/sim_motion_queue.c",
|
|
"web/worker/wasm-motion-queue.mjs",
|
|
"web/worker/sim-session.mjs",
|
|
"web/worker/program-runner.mjs",
|
|
"web/worker/authoritative-runtime.mjs",
|
|
"coverage/wasm-only-source-audit.report.json",
|
|
]
|
|
tests = [
|
|
run(["node", "web/worker/test_wasm_motion_authority.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_visible_completion.mjs"]),
|
|
run(["node", "web/worker/test_axis3_tutorial_persistence.mjs"]),
|
|
run(["node", "web/worker/test_axis3_tutorial_program.mjs"]),
|
|
]
|
|
report: dict[str, Any] = {
|
|
"schema": "wasm-motion-authority-t3.v1",
|
|
"status": "verified" if all(item["status"] == "verified" for item in tests) else "blocked",
|
|
"context_id": CONTEXT_ID,
|
|
"case": CASE,
|
|
"authority": {
|
|
"motion_authority": "wasm",
|
|
"motion_source": "wasm_motion_queue",
|
|
"js_authoritative_runtime_calls": 0,
|
|
"compatibility_runtime": "retained_non_selected_case_only",
|
|
},
|
|
"checkpoint": {
|
|
"schema": "sim_motion_queue_state.v1",
|
|
"raw_queue_state": True,
|
|
"controls": ["profile", "lookahead", "acceleration_limit", "jerk_limit", "paused"],
|
|
"continuous_recovery_endpoint_equal": True,
|
|
"damaged_state": "blocked",
|
|
},
|
|
"completion": {
|
|
"program_complete_before_queue_drain": True,
|
|
"task_stopped_requires_queue_depth_zero": True,
|
|
"abort_queue_depth": 0,
|
|
},
|
|
"first_divergent_tick": None,
|
|
"inputs": {path: sha256(ROOT / path) for path in inputs if (ROOT / path).is_file()},
|
|
"tests": tests,
|
|
"open_boundaries": [
|
|
"non-selected-case motion authority remains compatibility_open",
|
|
"T4 task/motion/home/jog/limit/HAL/IO canonical state remains open",
|
|
"full kinematics_motion and full LinuxCNC parity 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())
|