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

40 lines
3.6 KiB
Python

#!/usr/bin/env python3
"""Generate implementation-stage Tier-2 maps for all remaining modules."""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SOURCE = ROOT / "docs/p6/python-api-manifest.json"
ADAPTERS = {
"CAM": ("cam.worker.ts", "cam.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/CAMRuntimeProbe.cpp"),
"BIM": ("bim.worker.ts", "bim.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/BimRuntimeProbe.cpp"),
"Draft": ("draft.worker.ts", "draft.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/DraftRuntimeProbe.cpp"),
"Fem": ("fem.worker.ts", "fem.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/FemGenericFamilyProbe.cpp"),
"Material": ("material.worker.ts", "material.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/MaterialKernelProbe.cpp"),
"Points": ("points.worker.ts", "points.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/PointsRuntimeProbe.cpp"),
"Robot": ("robot-python.worker.ts", "robot.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/RobotRuntimeProbeFixed.cpp"),
"Sandbox": ("sandbox-python.worker.ts", "sandbox.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/SandboxRuntimeProbe.cpp"),
"Show": ("show-python.worker.ts", "show.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/ShowRuntimeProbe.cpp"),
"Spreadsheet": ("spreadsheet-python.worker.ts", "spreadsheet.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/SpreadsheetRuntimeProbe.cpp"),
"Surface": ("surface-python.worker.ts", "surface.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/SurfaceFamilyProbe.cpp"),
"Plot": ("plot-python.worker.ts", "plot.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/PlotRuntimeProbe.cpp"),
"TemplatePyMod": ("templatepymod-python.worker.ts", "templatepymod.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/TemplatePyModRuntimeProbe.cpp"),
"MeshPart": ("meshpart.worker.ts", "meshpart.pythonFamilyBatch", "src/WebAssembly/FreeCADCoreProbe/MeshPartRuntimeProbe.cpp"),
}
rows = json.loads(SOURCE.read_text(encoding="utf-8"))["records"]
digest = hashlib.sha256(SOURCE.read_bytes()).hexdigest()
outputs = []
for module, (worker, command, native_source) in ADAPTERS.items():
selected = [row for row in rows if row["module"] == module and row["tier"] == "tier-2-pure"]
if not selected:
continue
records = [{"apiId": row["id"], "name": row["name"], "kind": row["kind"], "family": row["family"], "sourcePath": row.get("evidence", {}).get("path"), "route": command, "adapterStatus": "module_adapter_ready_pending_method", "disposition": row["disposition"]} for row in selected]
output = {"schema": "freecad-web-python-family-adapter-manifest/v1", "taskId": f"FW-P6-FPA-IMPL-{module.upper()}-TIER2", "source": {"manifest": "docs/p6/python-api-manifest.json", "manifestSha256": digest}, "module": module, "tier": "tier-2-pure", "count": len(records), "route": {"worker": worker, "command": command, "nativeSource": native_source}, "records": records, "boundaries": ["module adapter readiness is not method-level evidence", "original disposition is preserved until the matching coverage gate"]}
out = ROOT / f"docs/p6/{module.lower()}-tier2-adapter-manifest.json"
out.write_text(json.dumps(output, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
outputs.append({"module": module, "count": len(records), "output": str(out.relative_to(ROOT)), "sha256": hashlib.sha256(out.read_bytes()).hexdigest()})
print(json.dumps({"generated": outputs, "total": sum(item["count"] for item in outputs)}, ensure_ascii=False))