"""Prepare source-bound implementation work without claiming user acceptance.""" import hashlib import json from pathlib import Path import subprocess from wbv2_execution_phase import implementation_only ROOT = Path(__file__).resolve().parents[1] def prepare(job, workflow, units, sources, changed, dependencies): context = json.loads(subprocess.check_output( ["node", "tools/web/print-task-context.mjs"], cwd=ROOT, text=True)) if not implementation_only(ROOT): subprocess.run(["node", "tools/web/check-task-context.mjs"], cwd=ROOT, check=True) dependencies = sorted(set(sources + changed + dependencies + [ "my-tools/wbv2_compilation_recipe.py", "my-tools/build_local_webengine.py", "tools/web/incremental-web-build.mjs", "tools/web/sync-web-engine-runtime.mjs", "tools/web/run-incremental-typecheck.mjs", ".emscripten-web", "build_web_blender6/CMakeCache.txt", "web/app/vite.config.ts", "web/package.json", "web/tsconfig.json", "web/protocol/scene-ir.ts", "web/protocol/web-engine.ts", "web/app/src/engine-client/WebEngineClient.ts", "web/app/src/workers/web-engine.worker.ts", ])) missing = [path for path in dependencies if not (ROOT / path).is_file()] if missing: raise ValueError(f"Missing compilation inputs: {missing}") result = { "status": "ready", "contractKind": "compilation_only", "summary": workflow, "workflow": workflow, "sourceUnits": sorted(set(units)), "routeIds": sorted(set(units)), "sourceReferences": sources, "changedFiles": changed, "dependencies": dependencies, "artifacts": ["build_web_blender6/bin/web_engine.wasm", "build_web_blender6/bin/web_engine.js", "build_blender_native/bin/blender"], "checks": [ {"id": "wasm-source-build", "argv": ["python3", "my-tools/build_local_webengine.py"], "cwd": ".", "kinds": ["source_build"], "timeoutSeconds": 1800}, {"id": "web-build", "argv": ["node", "tools/web/incremental-web-build.mjs"], "cwd": ".", "kinds": ["typecheck"], "dependsOn": ["wasm-source-build"], "timeoutSeconds": 180}, ], "cases": [], } document = { "schemaVersion": 1, "task": context["task"], "job": job, "parentSha256": hashlib.sha256( (ROOT / context["sourceDocuments"]["parentManifest"]).read_bytes()).hexdigest(), "acceptance": "deferred until user use; no behavioral acceptance claimed", "result": result, } target = ROOT / "my-tools/local-workflows" / f"{job}.json" target.parent.mkdir(parents=True, exist_ok=True) temporary = target.with_suffix(".json.tmp") temporary.write_text(json.dumps(document, indent=2) + "\n") temporary.replace(target) print(json.dumps({"job": job, "state": "prepared", "contractKind": "compilation_only"}))