Files
FreeCADWasmDev/tools/generate_tier4_restricted_manifest.py
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

22 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Generate explicit Tier-4 restricted/nonportable API boundaries."""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
source_path = ROOT / "docs/p6/python-api-manifest.json"
rows = json.loads(source_path.read_text(encoding="utf-8"))["records"]
selected = [row for row in rows if row["tier"] == "tier-4-restricted" or row["disposition"] in {"restricted", "nonportable"}]
records = []
for row in selected:
name = row["name"]
reason = "GUI/desktop dependency" if any(token in name.lower() for token in ("qt", "pyside", "pivy", "gui", "taskpanel", "browser")) else "nonportable or external runtime dependency"
records.append({"apiId": row["id"], "module": row["module"], "name": name, "family": row["family"], "tier": row["tier"], "disposition": row["disposition"], "reason": reason, "alternative": "Use React/Three.js/Worker route when an explicit Web equivalent exists"})
output = {"schema": "freecad-web-tier4-restricted-manifest/v1", "taskId": "FW-P6-FPA-IMPL-TIER4-RESTRICTED", "source": {"manifest": "docs/p6/python-api-manifest.json", "manifestSha256": hashlib.sha256(source_path.read_bytes()).hexdigest()}, "count": len(records), "records": records, "boundaries": ["restricted/nonportable API never executes through Web Python adapter", "alternatives are not semantic parity claims"]}
out = ROOT / "docs/p6/tier4-restricted-manifest.json"
out.write_text(json.dumps(output, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(json.dumps({"output": str(out.relative_to(ROOT)), "count": len(records), "sha256": hashlib.sha256(out.read_bytes()).hexdigest()}, ensure_ascii=False))