Files
workinf_Blender_Wasm/my-tools/wbv2_compilation_contract.py
mes123456 f3e21c6b98
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
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

51 lines
2.5 KiB
Python

"""Admission metadata for workflows whose behavioral verification is deferred."""
from __future__ import annotations
def compilation_requested(root, result):
from wbv2_autopilot import CONTROL, read_json
if result.get("contractKind") == "compilation_only":
return True
preferences = read_json(root / CONTROL / "preferences.json", {})
return preferences.get("verificationTiming") in {"on_user_use", "after_all_features"} and not result.get("cases")
def validate_compilation_shape(result):
if not isinstance(result, dict):
raise ValueError("compilation contract must be an object")
for field in ("sourceUnits", "routeIds", "sourceReferences", "dependencies", "artifacts", "changedFiles"):
values = result.get(field)
if not isinstance(values, list) or not all(isinstance(value, str) and value for value in values):
raise ValueError(f"compilation contract requires a path/identifier list: {field}")
for field in ("sourceUnits", "routeIds", "sourceReferences", "artifacts"):
if not result[field]:
raise ValueError(f"compilation contract requires nonempty {field}")
if not isinstance(result.get("workflow"), str) or not result["workflow"].strip():
raise ValueError("compilation contract requires a concrete workflow")
checks = result.get("checks")
if not isinstance(checks, list) or not checks:
raise ValueError("compilation contract requires executable build checks")
for check in checks:
if not isinstance(check, dict):
raise ValueError("compilation check must be an object")
for field in ("id", "cwd"):
if not isinstance(check.get(field), str) or not check[field]:
raise ValueError(f"compilation check requires {field}")
for field in ("argv", "kinds"):
values = check.get(field)
if not isinstance(values, list) or not values or not all(isinstance(value, str) and value for value in values):
raise ValueError(f"compilation check requires a nonempty {field} list")
cases = result.get("cases", [])
if not isinstance(cases, list):
raise ValueError("compilation cases must be a list when present")
def require_behavioral_contract(result):
if result.get("contractKind") == "compilation_only":
raise ValueError(
"behavioral verification unavailable: compilation-only contract; "
"add complete behavior checks and source-bound cases before explicit verify"
)