97 lines
5.4 KiB
Python
97 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the complete selected-case Web/WASM parity acceptance sequence."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
OUTPUT = Path("coverage/axis3-tutorial-web-wasm-complete-parity.report.json")
|
|
CONTEXT_ID = "linuxcnc-2.10.0-pre0-wasm-m1-py-c1"
|
|
CASE = "linuxcnc/configs/sim/axis/vismach/3axis-tutorial/3axis-tutorial.ini"
|
|
|
|
COMMANDS = (
|
|
("baseline", ("python3", "scripts/validate_baseline.py")),
|
|
("pointer", ("python3", "scripts/validate_task_pointer.py", "nextTask1.md", "--lock", "context-lock.json")),
|
|
("wasm_build", ("scripts/build-wasm.sh",)),
|
|
("panel_snapshot", ("node", "web/worker/test_panel_snapshot_projection.mjs")),
|
|
("panel_gates", ("node", "web/worker/test_panel_gate_matrix.mjs")),
|
|
("selected_case", ("node", "web/worker/test_axis3_selected_case.mjs")),
|
|
("visible_completion", ("node", "web/worker/test_axis3_visible_completion.mjs")),
|
|
("program_mdi", ("node", "web/worker/test_axis3_tutorial_program.mjs")),
|
|
("sequence_home_tool_ack", ("node", "web/worker/test_axis3_tutorial_sequence.mjs")),
|
|
("tool_io_probe", ("node", "web/worker/test_axis3_tutorial_tool_io.mjs")),
|
|
("preview_wasm_motion", ("node", "web/worker/test_wasm_preview.mjs")),
|
|
("motion_authority", ("node", "web/worker/test_wasm_motion_authority.mjs")),
|
|
("motion_checkpoint", ("node", "web/worker/test_wasm_motion_checkpoint.mjs")),
|
|
("canonical_state", ("node", "web/worker/test_wasm_canonical_state.mjs")),
|
|
("canonical_checkpoint", ("node", "web/worker/test_wasm_canonical_state_checkpoint.mjs")),
|
|
("persistence", ("node", "web/worker/test_axis3_tutorial_persistence.mjs")),
|
|
("trace", ("node", "web/worker/test_trace_export.mjs")),
|
|
("app_regression", ("bash", "-lc", "for test_file in web/app/test_*.mjs; do node \"$test_file\" >/dev/null || exit 1; done")),
|
|
("react_typecheck", ("npm", "--prefix", "web/react", "run", "typecheck")),
|
|
("react_build", ("npm", "--prefix", "web/react", "run", "build")),
|
|
)
|
|
|
|
|
|
def canonical(value: Any) -> str:
|
|
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
|
|
|
|
def digest(value: Any) -> str:
|
|
return hashlib.sha256(canonical(value).encode()).hexdigest()
|
|
|
|
|
|
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
|
|
root = root.resolve()
|
|
runs = []
|
|
for name, command in COMMANDS:
|
|
result = subprocess.run(command, cwd=root, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
|
|
runs.append({"name": name, "command": list(command), "status": "passed" if result.returncode == 0 else "failed", "exit_code": result.returncode, "output_bytes": len(result.stdout.encode()), "output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest()})
|
|
passed = all(row["status"] == "passed" for row in runs)
|
|
report: dict[str, Any] = {
|
|
"schema": "axis3-tutorial-web-wasm-complete-parity.v2",
|
|
"task_id": "PANEL-15-SELECTED-CASE-ACCEPTANCE",
|
|
"context_id": CONTEXT_ID,
|
|
"case": CASE,
|
|
"status": "verified" if passed else "blocked",
|
|
"implementation_status": "verified" if passed else "blocked",
|
|
"candidate_eligible": passed,
|
|
"release_action": "ALLOW_RELEASE" if passed else "STOP_RELEASE",
|
|
"scope": "selected_case_web_wasm_simulation",
|
|
"authority_chain": ["linuxcnc_source", "native_fixture", "wasm_core", "dedicated_worker", "react_projection"],
|
|
"source_contract": {"axis": "linuxcnc/src/emc/usr_intf/axis/scripts/axis.py", "case_ini": CASE, "case_hal": "linuxcnc/configs/sim/axis/vismach/3axis-tutorial/3axis-tutorial.hal", "vismach_program": "linuxcnc/configs/sim/axis/vismach/3axis-tutorial/3axis-tutorial"},
|
|
"feature_matrix": ["load_program", "toolpath_preview", "estop_reset", "power_on", "reset", "home", "execute_gcode", "realtime_path", "realtime_coordinates", "button_gates", "mdi", "jog", "spindle", "coolant", "tool_change", "probe", "checkpoint_recovery", "diagnostics", "accessibility_layout"],
|
|
"commands": runs,
|
|
"passed_command_count": sum(row["status"] == "passed" for row in runs),
|
|
"required_command_count": len(COMMANDS),
|
|
"boundaries": ["scope is the exact 3axis-tutorial case", "real hardware and realtime kernel remain REAL-EXCLUDED", "historical full-configuration/oracle reports are not promoted by this selected-case report"],
|
|
"failure_samples": [] if passed else [row for row in runs if row["status"] != "passed"],
|
|
"report_sha256": None,
|
|
}
|
|
report["report_sha256"] = digest({key: value for key, value in report.items() if key != "report_sha256"})
|
|
destination = output if output.is_absolute() else root / output
|
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
destination.write_text(json.dumps(report, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
|
|
return report
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--repo-root", type=Path, default=ROOT)
|
|
parser.add_argument("--output", type=Path, default=OUTPUT)
|
|
args = parser.parse_args()
|
|
report = generate(args.repo_root.resolve(), args.output)
|
|
print(f"axis3_tutorial_complete_parity={report['status']} passed={report['passed_command_count']}/{report['required_command_count']}")
|
|
return 0 if report["status"] == "verified" else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|