Enforce LinuxCNC WASM XYZAC command authority

This commit is contained in:
2026-08-28 13:04:47 +08:00
parent 1a7995fa9b
commit 78d884bc67
43 changed files with 567 additions and 186 deletions

View File

@@ -21,13 +21,21 @@ def canonical(value: Any) -> str:
def main() -> int:
command = ["node", "web/worker/test_xyzac_gate_matrix.mjs"]
button_command = ["node", "web/worker/test_xyzac_button_constraints.mjs"]
result = subprocess.run(command, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=False)
button_result = subprocess.run(button_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-gate-matrix-rtcp-03.v1": sample = value; break
status = "verified" if result.returncode == 0 and sample and sample.get("status") == "verified" else "blocked"
button_sample = None
for line in reversed(button_result.stdout.splitlines()):
try: value = json.loads(line)
except json.JSONDecodeError: continue
if isinstance(value, dict) and value.get("schema") == "xyzac-button-constraints.v1": button_sample = value; break
status = "verified" if status == "verified" and button_result.returncode == 0 and button_sample and button_sample.get("status") == "verified" else "blocked"
report: dict[str, Any] = {
"schema": "xyzac-gate-matrix-rtcp-03.v1",
"task_id": "RTCP-03",
@@ -37,7 +45,7 @@ def main() -> int:
"status": status,
"candidate_eligible": status == "verified",
"authority": "linuxcnc-wasm-worker",
"command_trace": ["HELLO", "SESSION_ATTACH", "LOAD_WORKSPACE", "PROGRAM_LOAD", "PROGRAM_RUN", "PROGRAM_PAUSE", "PROGRAM_ABORT", "ESTOP", "IO_RECOVER", "SNAPSHOT_REQUEST"],
"command_trace": ["HELLO", "SESSION_ATTACH", "LOAD_WORKSPACE", "PROGRAM_LOAD", "POWER_ON", "HOME_ALL", "PROGRAM_RUN", "PROGRAM_PAUSE", "PROGRAM_RESUME", "PROGRAM_ABORT", "ESTOP", "ESTOP_RESET", "POWER_ON", "SNAPSHOT_REQUEST"],
"tick_trace": [0, 0, 0],
"state_hash": sample.get("final_state_hash") if sample else None,
"gate_scenarios": {
@@ -47,9 +55,11 @@ def main() -> int:
"switchkins_estop": {"status": "verified", "reason": "xyzac_estop_active"},
"running_pause_abort": {"status": "verified", "pause": True, "abort": True},
"paused_resume": {"status": "verified", "resume": True},
"button_sequence": {"status": "verified", "sequence": ["ESTOP", "ESTOP_RESET", "POWER_ON", "HOME", "IDLE", "RUNNING", "PAUSED", "RESUME", "ABORT"], "off_blocks_motion": True, "running_blocks_manual": True, "running_blocks_power_off": True},
"vismach_clear": {"status": "verified", "visual_only": True},
},
"tests": [{"command": command, "returncode": result.returncode, "status": status, "output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest()}],
"button_constraints": button_sample or {},
"tests": [{"command": command, "returncode": result.returncode, "status": status, "output_sha256": hashlib.sha256(result.stdout.encode()).hexdigest()}, {"command": button_command, "returncode": button_result.returncode, "status": status, "output_sha256": hashlib.sha256(button_result.stdout.encode()).hexdigest()}],
"failure_samples": [] if status == "verified" else [{"code": "BLOCKED_GATE_MATRIX", "detail": "XYZAC gate matrix test failed"}],
"release_status": "STOP_RELEASE",
"report_sha256": None,