29 lines
2.1 KiB
Python
29 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
manifest_path = ROOT / "docs/p6/python-api-manifest.json"
|
|
evidence_path = ROOT / "docs/p6/python-api-runtime-evidence.json"
|
|
manifest = json.loads(manifest_path.read_text())
|
|
evidence = json.loads(evidence_path.read_text())
|
|
exposed = [row for row in manifest["records"] if row["tier"] == "tier-1-readonly" and row["disposition"] == "exposed"]
|
|
valid = len(exposed) == 16 and all(row.get("dispositionEvidence") for row in exposed)
|
|
report = {
|
|
"schema": "freecad-web-p6-python-api-readonly-gate/v1",
|
|
"taskId": "FW-P6-FPA-F1",
|
|
"result": "pass_with_pending" if valid else "fail",
|
|
"coverage": {"inventoryRecords": len(manifest["records"]), "exposedReadonlyRecords": len(exposed), "exposedTotalRecords": sum(row["disposition"] == "exposed" for row in manifest["records"]), "restrictedRecords": sum(row["disposition"] == "restricted" for row in manifest["records"]), "plannedRecords": sum(row["disposition"] == "planned" for row in manifest["records"])},
|
|
"evidence": {"indexedNames": evidence["count"], "indexSha256": hashlib.sha256(evidence_path.read_bytes()).hexdigest(), "manifestSha256": hashlib.sha256(manifest_path.read_bytes()).hexdigest()},
|
|
"byModule": dict(sorted(Counter(row["module"] for row in exposed).items())),
|
|
"records": [{"id": row["id"], "module": row["module"], "name": row["name"], "artifacts": row["dispositionEvidence"]} for row in exposed],
|
|
"boundaries": ["Only passing native python-api runtime artifacts are accepted.", "The remaining planned records require later family probes and are not implied by this partial gate."],
|
|
}
|
|
out = ROOT / "docs/p6/python-api-readonly-gate.json"
|
|
out.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
|
(ROOT / "docs/freecad-p6-python-api-readonly-gate.log").write_text(json.dumps({"result": report["result"], "coverage": report["coverage"]}) + "\n")
|
|
print(json.dumps({"result": report["result"], "coverage": report["coverage"]}, ensure_ascii=False))
|
|
raise SystemExit(0 if valid else 1)
|