Implement AXIS parity UI and execution baseline
This commit is contained in:
86
scripts/generate_sim_case_batch_s8_03.py
Normal file
86
scripts/generate_sim_case_batch_s8_03.py
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate S8-03 XZ case-batch startup evidence."""
|
||||
|
||||
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]
|
||||
RUNNER = ("node", "web/worker/test_sim_case_batch_s8_03.mjs")
|
||||
INPUTS = (
|
||||
"coverage/sim-case-catalog.report.json",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz.ini",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz_both.ini",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_auto.ini",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xzbase.inc",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz.var",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz.tbl",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz_cmds.hal",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_cmds.hal",
|
||||
"linuxcnc/configs/sim/axis/ja_tests/xz/xz_both_auto_cmds.hal",
|
||||
"web/workspace/sim-case-loader.mjs",
|
||||
"web/workspace/hal-configuration.mjs",
|
||||
"web/worker/test_sim_case_batch_s8_03.mjs",
|
||||
)
|
||||
|
||||
|
||||
def canonical(value: Any) -> str:
|
||||
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
||||
|
||||
|
||||
def digest(value: bytes) -> str:
|
||||
return hashlib.sha256(value).hexdigest()
|
||||
|
||||
|
||||
def artifact(path: str) -> dict[str, Any]:
|
||||
value = ROOT / path
|
||||
return {"path": path, "status": "missing"} if not value.is_file() else {"path": path, "bytes": value.stat().st_size, "sha256": digest(value.read_bytes()), "status": "present"}
|
||||
|
||||
|
||||
def generate(output: Path) -> dict[str, Any]:
|
||||
result = subprocess.run(RUNNER, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
|
||||
sample = None
|
||||
for line in reversed(result.stdout.decode("utf-8", errors="replace").splitlines()):
|
||||
if line.lstrip().startswith("{"):
|
||||
try:
|
||||
sample = json.loads(line)
|
||||
break
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
passed = result.returncode == 0 and sample and sample.get("status") == "verified" and len(sample.get("cases", [])) == 3 and all(row.get("state") == "TASK_READY" for row in sample["cases"])
|
||||
report: dict[str, Any] = {
|
||||
"schema": "sim-case-batch-s8-03-report.v1",
|
||||
"task_id": "S8-03",
|
||||
"context_id": "linuxcnc-2.10.0-pre0-wasm-m1-py-c1",
|
||||
"status": "verified" if passed else "blocked",
|
||||
"implementation_status": "verified" if passed else "blocked",
|
||||
"fixture_policy": "user-authorized-runtime-copy",
|
||||
"execution": {"command": list(RUNNER), "returncode": result.returncode, "status": "PASSED" if result.returncode == 0 else "FAILED", "stdout_sha256": digest(result.stdout), "stderr_sha256": digest(result.stderr), "sample": sample},
|
||||
"checks": {"three_case_batch": {"status": "verified" if passed else "blocked", "cases": 3}, "task_ready": {"status": "verified" if passed else "blocked"}, "hal_preflight": {"status": "verified" if passed else "blocked"}, "fixture_hashes": {"status": "verified" if passed else "blocked"}},
|
||||
"inputs": [artifact(path) for path in INPUTS],
|
||||
"boundaries": ["XZ identity/BOTH/AUTO only", "runtime fixtures are copied from real LinuxCNC execution or the same case's xz.tbl", "other cases with unresolved resources remain blocked", "no ABI/protocol/schema change"],
|
||||
}
|
||||
report["report_sha256"] = hashlib.sha256(canonical({key: value for key, value in report.items() if key != "report_sha256"}).encode()).hexdigest()
|
||||
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("--report", type=Path, default=Path("coverage/sim-case-batch-s8-03.report.json"))
|
||||
args = parser.parse_args()
|
||||
report = generate(args.report)
|
||||
print(f"sim_case_batch_s8_03={report['status']} report_sha256={report['report_sha256']}")
|
||||
return 0 if report["status"] == "verified" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user