Files
workinf_Blender_Wasm/tools/web/check-wbv2-p7-002-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

75 lines
3.9 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import pathlib
import sys
import bpy
RECEIPT_NAME = "WBV2-P7-002-AtomicFamilyGapQueueReceipt"
CUBE_NAME = "WBV2P7002AtomicGapQueueCube"
BEHAVIORS = ["desktopPositive", "wasmMutation", "saveReopenExact"]
def state():
scene = bpy.context.scene
text = bpy.data.texts.get(RECEIPT_NAME)
cube = bpy.data.objects.get(CUBE_NAME)
if text is None or cube is None:
raise RuntimeError("atomic queue fixture is missing receipt or cube")
return {"sceneId": "scene:" + scene.name, "cubeId": "object:" + cube.name, "receipt": json.loads(text.as_string())}
def validate(receipt):
if receipt.get("schemaVersion") != 1 or receipt.get("receiptId") != "workflow:generate_atomic_family_gap_queue":
raise RuntimeError("atomic queue receipt identity is invalid")
parent = receipt.get("parent", {})
queue = receipt.get("queue", {})
tasks = receipt.get("tasks", [])
if (parent.get("task") != "WBV2-P7-001" or parent.get("manifestPath") != "tests/golden/WBV2-P7-001/manifest.json" or
len(parent.get("manifestSha256", "")) != 64 or len(parent.get("receiptSha256", "")) != 64 or
queue.get("activeCount") != 1 or queue.get("plannedCount") != 44 or queue.get("behaviors") != BEHAVIORS or
queue.get("implementationClasses") != ["LOCAL_BOUNDED"] or len(tasks) != 45 or receipt.get("nextTask") != "WBV2-P7-003"):
raise RuntimeError("atomic queue parent or cardinality is invalid")
active = [task for task in tasks if task.get("state") == "active" and task.get("ready") is True]
if len(active) != 1 or queue.get("activeTaskId") != active[0].get("id"):
raise RuntimeError("atomic queue must have exactly one active ready task")
ids = set()
for index, task in enumerate(tasks):
if (task.get("id") in ids or not isinstance(task.get("id"), str) or task.get("parityId") != task.get("capabilityId") or
task.get("behavior") != BEHAVIORS[index % 3] or task.get("implementationClass") != "LOCAL_BOUNDED" or
task.get("parentTask") != "WBV2-P7-001" or len(task.get("parentReceiptSha256", "")) != 64 or
task.get("state") != ("active" if index == 0 else "pending") or task.get("ready") is not (index == 0)):
raise RuntimeError("atomic queue ordering or task state is invalid")
ids.add(task["id"])
if receipt["tasks"] != sorted(tasks, key=lambda value: (value["capabilityId"], BEHAVIORS.index(value["behavior"]))):
raise RuntimeError("atomic queue ordering 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-002-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"atomic queue save/reopen drift: {before} != {after}")
report = {"schemaVersion": 1, "task": "WBV2-P7-002", "operation": "GENERATE_ATOMIC_FAMILY_GAP_QUEUE_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-002-desktop-ok tasks={len(after['receipt']['tasks'])} active=1 planned=44 saveReopen=exact")
if __name__ == "__main__":
main()