Files
FreeCADWasmDev/tools/generate_object_family_batches.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

23 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Generate deterministic module batches for object-family execution."""
import hashlib
import json
from collections import defaultdict
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
matrix_path = ROOT / "docs/p6/object-contract-matrix.json"
matrix = json.loads(matrix_path.read_text())
batches = defaultdict(list)
for row in matrix["records"]:
batches[(row["adapterFamily"], row["module"])].append(row["id"])
report = {
"schema": "freecad-web-object-family-batches/v1",
"source": {"matrix": "docs/p6/object-contract-matrix.json", "matrixSha256": hashlib.sha256(matrix_path.read_bytes()).hexdigest()},
"policy": "one module batch uses one adapter family and one evidence gate; no per-object facade duplication",
"batches": [{"family": family, "module": module, "count": len(ids), "objectIds": sorted(ids), "status": "planned"} for (family, module), ids in sorted(batches.items())],
}
out = ROOT / "docs/p6/object-family-batches.json"
out.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
print(json.dumps({"output": str(out.relative_to(ROOT)), "batches": len(report["batches"]), "objects": sum(x["count"] for x in report["batches"]), "sha256": hashlib.sha256(out.read_bytes()).hexdigest()}, ensure_ascii=False))