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

81 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""Prepare the final primary React product integration as one business batch."""
from __future__ import annotations
import hashlib
import json
from datetime import datetime, timezone
from pathlib import Path
from implementation_first import all_implementation_ready_ids
from scheduler_progress import cooling_ids, retry_details
ROOT = Path(__file__).resolve().parents[1]
SOURCE = ROOT / "docs/current/product-business-backlog.json"
STATE = ROOT / "docs/current/task-state.json"
OUTPUT = ROOT / "docs/current/module-batch-manifest.json"
def main() -> int:
payload = json.loads(SOURCE.read_text(encoding="utf-8"))
ready = all_implementation_ready_ids()
records = [row for row in payload.get("records", []) if isinstance(row, dict) and str(row.get("id")) not in ready]
cooling = cooling_ids(candidates={row["id"] for row in records})
deferred_ids = {row["id"] for row in records if row["id"] in cooling}
records = [row for row in records if row["id"] not in cooling]
if not records:
result = {
"schema": "freecad-web-module-function-batch/v1",
"status": "no_ready_batch",
"generatedAt": datetime.now(timezone.utc).isoformat(),
"strategy": "module-business-first-deferred-validation",
"reason": "all product integration business records have implementation receipts",
"records": [],
"queue": [],
**retry_details(deferred_ids),
}
OUTPUT.write_text(json.dumps(result, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
print(json.dumps({"status": result["status"], "records": 0}, ensure_ascii=False))
return 0
identity = "|".join(["Web", "product-integration", "react-primary-shell", *(str(row["id"]) for row in records)])
batch_id = hashlib.sha256(identity.encode("utf-8")).hexdigest()[:24]
state = json.loads(STATE.read_text(encoding="utf-8"))
result = {
"schema": "freecad-web-module-function-batch/v1",
"status": "ready",
"generatedAt": datetime.now(timezone.utc).isoformat(),
"taskId": state.get("active_task"),
"batchId": batch_id,
"strategy": "module-business-first-deferred-validation",
"businessBundle": {
"module": "Web",
"implementationUnit": "primary-react-product-shell",
"selectedRecordsAreCoverageAnchors": True,
},
"minimumRecords": 1,
"singletonFallback": len(records) == 1,
"selected": {
"module": "Web",
"tier": "product-integration",
"family": "react-primary-shell",
"recordCount": len(records),
"dispositionCounts": {"not_implemented": len(records)},
},
"fields": ["id", "name", "disposition", "source", "sourceLine"],
"records": [[row["id"], row["name"], "not_implemented", row["source"], row.get("sourceLine", 1)] for row in records],
"queue": [{"module": "Web", "tier": "product-integration", "family": "react-primary-shell", "unresolved": len(records), "nextSize": len(records)}],
"boundaries": [
"This is one product workflow implementation, not twelve independent API tasks.",
"React owns interaction; all CAD computation and document semantics remain in module WASM workers.",
"Implementation writes build receipts only; validation remains disabled.",
],
}
OUTPUT.write_text(json.dumps(result, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
print(json.dumps({"status": "ready", "batchId": batch_id, "module": "Web", "family": "react-primary-shell", "records": len(records)}, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())