Implement AXIS parity UI and execution baseline
This commit is contained in:
57
scripts/generate_recovery_ux_report.py
Normal file
57
scripts/generate_recovery_ux_report.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate deterministic P7-05 recovery/offline/error UX evidence."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
OUTPUTS = (Path("web/app/recovery-panel.mjs"), Path("web/app/project-workflow.mjs"), Path("web/app/app.mjs"), Path("web/app/test_recovery_ux.mjs"), Path("web/workspace/migration.mjs"))
|
||||
|
||||
|
||||
def canonical(value: Any) -> str:
|
||||
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
||||
|
||||
|
||||
def sha256(path: Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def generate(root: Path, report_path: Path) -> dict[str, Any]:
|
||||
ux = subprocess.run(["node", "web/app/test_recovery_ux.mjs"], cwd=root, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
|
||||
workflow = subprocess.run(["node", "web/app/test_frontend_m3.mjs"], cwd=root, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
|
||||
report: dict[str, Any] = {
|
||||
"schema": "recovery-ux-report.v1",
|
||||
"task_id": "P7-05",
|
||||
"context_id": "linuxcnc-2.10.0-pre0-wasm-m1-py-c1",
|
||||
"status": "verified" if ux.returncode == 0 and workflow.returncode == 0 else "blocked",
|
||||
"states": ["idle", "validating", "replaying", "recovered", "aborted", "blocked", "network_required"],
|
||||
"actions": {"blocked": ["retry", "abort"], "network_required": ["retry_online"], "recovered": ["continue"], "half_commit": "explicit message"},
|
||||
"diagnostics": ["reason", "state_hash", "applied", "half_commits", "missing", "corrupted", "permission", "quota"],
|
||||
"tests": {"ux": {"status": "verified" if ux.returncode == 0 else "blocked", "stdout": ux.stdout.decode("utf-8", errors="replace")[-1200:]}, "workflow": {"status": "verified" if workflow.returncode == 0 else "blocked", "stdout": workflow.stdout.decode("utf-8", errors="replace")[-1200:]}},
|
||||
"outputs": [{"path": path.as_posix(), "bytes": (root / path).stat().st_size, "sha256": sha256(root / path)} for path in OUTPUTS],
|
||||
"known_boundaries": ["browser multi-engine fault matrix is P8-04", "release gate remains STOP_RELEASE"],
|
||||
}
|
||||
report["report_sha256"] = hashlib.sha256(canonical(report).encode("utf-8")).hexdigest()
|
||||
report_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
report_path.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(description=__doc__)
|
||||
parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
|
||||
parser.add_argument("--report", type=Path, default=Path("coverage/recovery-ux.report.json"))
|
||||
args = parser.parse_args()
|
||||
report = generate(args.repo_root.resolve(), args.repo_root.resolve() / args.report)
|
||||
print(f"recovery_ux={report['status']} states={len(report['states'])}")
|
||||
return 0 if report["status"] == "verified" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user