Files
workinf_Blender_Wasm/tools/web/check-wbv2-p7-001-desktop.py
mes123456 c2c65d3a09
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Rebuild local Blender WASM environment and recovery evidence
2026-08-27 20:22:15 +08:00

82 lines
4.0 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import pathlib
import sys
import bpy
RECEIPT_NAME = "WBV2-P7-001-ClusterFullBlenderGapInventoryReceipt"
CUBE_NAME = "WBV2P7001GapInventoryCube"
def state():
scene = bpy.context.scene
receipt_text = bpy.data.texts.get(RECEIPT_NAME)
cube = bpy.data.objects.get(CUBE_NAME)
if receipt_text is None or cube is None:
raise RuntimeError("gap inventory fixture is missing receipt or cube")
return {"sceneId": "scene:" + scene.name, "cubeId": "object:" + cube.name, "receipt": json.loads(receipt_text.as_string())}
def validate(receipt):
if receipt.get("schemaVersion") != 1 or receipt.get("receiptId") != "workflow:cluster_full_blender_gap_inventory":
raise RuntimeError("gap inventory receipt identity is invalid")
source = receipt.get("inventorySource", {})
if source.get("entryCount") != receipt.get("summary", {}).get("inventoryEntries") or len(source.get("sha256", "")) != 64:
raise RuntimeError("gap inventory source binding is invalid")
clusters = receipt.get("clusters", [])
summary = receipt.get("summary", {})
if len(clusters) != summary.get("clusterCount") or len(clusters) != 15:
raise RuntimeError("gap inventory clusters are incomplete")
if summary.get("currentParityClaims") != 0 or summary.get("currentParityLevel") != "L0":
raise RuntimeError("gap inventory must not claim parity")
if summary.get("webGapEntries") != summary.get("inventoryEntries"):
raise RuntimeError("all unproven inventory entries must remain explicit gaps")
ids = []
for cluster in clusters:
ids.append(cluster.get("capabilityId"))
if (cluster.get("entryCount", 0) != cluster.get("legacyCompleted", 0) + cluster.get("legacyPending", 0) + cluster.get("legacyActive", 0) or
cluster.get("currentParityLevel") != "L0" or cluster.get("completionClass") != "METADATA_ONLY" or
cluster.get("evidenceStatus") != "NOT_RUN" or cluster.get("webStatus") != "GAP" or
not isinstance(cluster.get("riskScore"), int) or not cluster.get("representativeIds")):
raise RuntimeError("gap inventory cluster is not fail-closed")
if len(set(ids)) != len(ids) or receipt.get("riskRanking") != [cluster["capabilityId"] for cluster in sorted(clusters, key=lambda value: (-value["riskScore"], value["capabilityId"]))]:
raise RuntimeError("gap inventory risk ranking is not deterministic")
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --factory-startup --python check-wbv2-p7-001-desktop.py -- FIXTURE REPORT")
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
before = state()
validate(before["receipt"])
temporary = fixture.with_name(f"{fixture.stem}-reopen.blend")
try:
bpy.ops.wm.save_as_mainfile(filepath=str(temporary), check_existing=False, compress=True)
bpy.ops.wm.open_mainfile(filepath=str(temporary), load_ui=False)
after = state()
finally:
temporary.unlink(missing_ok=True)
if before != after:
raise RuntimeError(f"gap inventory save/reopen drift: {before} != {after}")
report = {
"schemaVersion": 1,
"task": "WBV2-P7-001",
"operation": "CLUSTER_FULL_BLENDER_GAP_INVENTORY_DESKTOP",
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
"state": after,
"saveReopen": "EXACT",
"blenderVersion": bpy.app.version_string,
}
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print(f"wbv2-p7-001-desktop-ok clusters={len(after['receipt']['clusters'])} entries={after['receipt']['summary']['inventoryEntries']} webGap={after['receipt']['summary']['webGapEntries']} saveReopen=exact")
if __name__ == "__main__":
main()