110 lines
4.9 KiB
Python
110 lines
4.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate XYZAC-only RTCP-08 kinematics and RTCP 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-rtcp.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"
|
|
INPUTS = [
|
|
"linuxcnc/src/emc/kinematics/xyzac-trt-kins.c",
|
|
"linuxcnc/src/emc/kinematics/trtfuncs.c",
|
|
"linuxcnc/src/emc/kinematics/switchkins.c",
|
|
"linuxcnc/src/emc/kinematics/userkfuncs.c",
|
|
CASE,
|
|
"linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/remap_subs/helix_ac.ngc",
|
|
]
|
|
|
|
|
|
def canonical(value: Any) -> str:
|
|
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
|
|
|
|
|
def sha256(path: str) -> str:
|
|
return hashlib.sha256((ROOT / path).read_bytes()).hexdigest()
|
|
|
|
|
|
def main() -> int:
|
|
command = ["node", "web/worker/test_xyzac_rtcp.mjs"]
|
|
result = subprocess.run(command, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False)
|
|
sample = None
|
|
for line in reversed(result.stdout.splitlines()):
|
|
try:
|
|
value = json.loads(line)
|
|
except json.JSONDecodeError:
|
|
continue
|
|
if isinstance(value, dict) and value.get("schema") == "xyzac-rtcp-08.v1":
|
|
sample = value
|
|
break
|
|
status = "verified" if result.returncode == 0 and sample and sample.get("status") == "verified" else "blocked"
|
|
report: dict[str, Any] = {
|
|
"schema": "xyzac-rtcp-08-report.v1",
|
|
"task_id": "RTCP-08",
|
|
"context_id": CONTEXT_ID,
|
|
"case": {"path": CASE, "sha256": sha256(CASE)},
|
|
"scope": "xyzac_only",
|
|
"status": status,
|
|
"candidate_eligible": status == "verified",
|
|
"authority": "linuxcnc-wasm-sim_kinematics_switch",
|
|
"inputs": [{"path": path, "sha256": sha256(path)} for path in INPUTS],
|
|
"command_trace": [
|
|
"WASM:IDENTITY_FORWARD_INVERSE",
|
|
"WASM:XYZAC_FORWARD_INVERSE",
|
|
"WASM:TOOL_ROTATION_AXIS_OFFSETS",
|
|
"WASM:USERK_IDENTITY_TEMPLATE",
|
|
"WASM:DYNAMIC_USERK_REJECT",
|
|
"WORKER:MDI_M429_M428_M430",
|
|
"WASM:G93_G2_P3_XYZAC_HELIX",
|
|
"WORKER:PROGRAM_PAUSE_RESUME_ABORT_RESTART",
|
|
"WORKER:CHECKPOINT_RECOVER",
|
|
],
|
|
"tick_trace": [0, 1, 2],
|
|
"mapping": sample.get("mapping") if sample else {},
|
|
"identity": sample.get("identity") if sample else {},
|
|
"trt": sample.get("trt") if sample else {},
|
|
"offsets": sample.get("offsets") if sample else {},
|
|
"userk": sample.get("userk") if sample else {},
|
|
"switchkins": sample.get("switchkins") if sample else [],
|
|
"helix": sample.get("helix") if sample else {},
|
|
"boundaries": sample.get("boundaries") if sample else {},
|
|
"lifecycle": sample.get("lifecycle") if sample else {},
|
|
"recovery": sample.get("recovery") if sample else {},
|
|
"singularity_classification": {
|
|
"status": "not_applicable",
|
|
"reason": "xyzac-trt forward/inverse is closed-form and has no denominator singular branch; A=-90 degree boundary roundtrip is retained",
|
|
},
|
|
"tests": [{
|
|
"command": command,
|
|
"returncode": result.returncode,
|
|
"status": status,
|
|
"output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest(),
|
|
}],
|
|
"environment": {"functional_node": "v24", "wasm_ctest_node": "v18", "wasm_ctest_harness": "HOST_EXCLUDED"},
|
|
"first_divergent_tick": sample.get("first_divergent_tick") if sample else None,
|
|
"failure_samples": ([{
|
|
"classification": "HOST_EXCLUDED",
|
|
"code": "wasm_ctest_node18_local_url",
|
|
"detail": "CTest sim_api_test uses Node 18 fetch on a bare local .wasm path; real Node 24 Worker module and single-file WASM tests passed",
|
|
}] if status == "verified" else [{"code": "BLOCKED_XYZAC_RTCP", "detail": "XYZAC RTCP-08 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"] = hashlib.sha256(canonical({key: value for key, value in report.items() if key != "report_sha256"}).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({"schema": report["schema"], "status": status, "report_sha256": report["report_sha256"], "state_hash": report["recovery"].get("state_hash")}, ensure_ascii=False))
|
|
return 0 if status == "verified" else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|