Files
linuxcncWebWASM/scripts/generate_tp_s1b_report.py

17 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Generate deterministic S1-02B TP pause/resume evidence."""
from __future__ import annotations
import argparse,hashlib,json,subprocess
from pathlib import Path
from typing import Any
OUTPUTS=(Path("wasm-core/include/sim_motion_queue.h"),Path("wasm-core/src/sim_motion_queue.c"),Path("wasm-core/tests/sim_motion_queue_test.c"))
def canonical(v:Any)->str:return json.dumps(v,ensure_ascii=False,sort_keys=True,separators=(",",":"))
def sha256(p:Path)->str:return hashlib.sha256(p.read_bytes()).hexdigest()
def generate(root:Path,out:Path)->dict[str,Any]:
r=subprocess.run([str(root/"build-native/sim_motion_queue_test")],cwd=root,stdout=subprocess.PIPE,stderr=subprocess.PIPE,check=False);w=subprocess.run(["node","build-wasm/sim_motion_queue_wasm_test.js"],cwd=root,stdout=subprocess.PIPE,stderr=subprocess.PIPE,check=False)
report={"schema":"tp-s1b-report.v1","task_id":"S1-02B","context_id":"linuxcnc-2.10.0-pre0-wasm-m1-py-c1","status":"verified" if r.returncode==0 and w.returncode==0 else "blocked","features":["pause without tick drift","resume continuation","exact-stop boundary velocity reset","blend multi-segment queue endpoint"],"tests":{"native":{"status":"verified" if r.returncode==0 else "blocked"},"wasm":{"status":"verified" if w.returncode==0 else "blocked"}},"outputs":[{"path":p.as_posix(),"bytes":(root/p).stat().st_size,"sha256":sha256(root/p)} for p in OUTPUTS]}
report["report_sha256"]=hashlib.sha256(canonical(report).encode()).hexdigest();out.parent.mkdir(parents=True,exist_ok=True);out.write_text(json.dumps(report,ensure_ascii=False,sort_keys=True,indent=2)+"\n");return report
def main()->int:
p=argparse.ArgumentParser();p.add_argument("--repo-root",type=Path,default=Path(__file__).resolve().parents[1]);p.add_argument("--report",type=Path,default=Path("coverage/tp-s1b.report.json"));a=p.parse_args();r=generate(a.repo_root.resolve(),a.repo_root.resolve()/a.report);print(f"tp_s1b={r['status']}");return 0 if r["status"]=="verified" else 1
if __name__=="__main__":raise SystemExit(main())