Files
workinf_Blender_Wasm/tools/web/generate-wbv2-animation-render-slice.mjs
mes123456 81113159dc
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
feat(web): continue source-backed implementation waves
2026-08-29 05:46:53 +08:00

56 lines
7.5 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const abs = (file) => path.join(root, file);
const read = (file) => fs.readFileSync(abs(file), "utf8");
const json = (file) => JSON.parse(read(file));
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
const task = process.argv[process.argv.indexOf("--task") + 1] ?? "WBV2-P30-001";
const config = {
"WBV2-P30-001": { parent: "WBV2-P30-000", next: "WBV2-P30-002", family: "ANIMATION.NLA_WORKBENCH", marker: "animationRenderCommands", files: ["web/protocol/animation-render-commands.ts", "web/app/src/app/App.tsx", "web/protocol/web-engine.ts"] },
"WBV2-P30-002": { parent: "WBV2-P30-001", next: "WBV2-P30-003", family: "RENDER.SCENE_PROPERTIES", marker: "set_render_properties", files: ["blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp", "blender-5.2.0/source/blender/web_engine/web_engine_api.cpp", "web/protocol/animation-render-commands.ts", "web/app/src/app/App.tsx"] },
"WBV2-P30-003": { parent: "WBV2-P30-002", next: "WBV2-P30-004", family: "GEOMETRY.NON_MESH_MEDIA", marker: "nonMeshGeometryCommands", files: ["web/protocol/nonmesh-geometry-commands.ts", "web/protocol/web-engine.ts", "web/app/src/app/App.tsx"] },
"WBV2-P30-004": { parent: "WBV2-P30-003", next: "WBV2-P31-000", family: "P30.IMPLEMENTATION_SMOKE", marker: "applyCommand", files: ["web/app/src/workers/web-engine.worker.ts", "web/app/src/vendor/blender/web_engine.wasm"] },
};
const selected = config[task];
if (!selected) throw new Error(`unsupported P30 task ${task}`);
const parentPath = `tests/golden/${selected.parent}/manifest.json`;
const parent = json(parentPath);
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, task);
for (const file of selected.files) assert.ok(fs.existsSync(abs(file)), file);
assert.match(read(selected.files[0]), new RegExp(selected.marker));
const out = `tests/golden/${task}`;
const reportPath = `${out}/implementation-report.json`;
const statusPath = `docs/status/${task}.md`;
fs.mkdirSync(abs(out), { recursive: true });
fs.writeFileSync(abs(reportPath), `${JSON.stringify({ schemaVersion: 1, task, operation: "IMPLEMENT_ANIMATION_RENDER_FAMILY", status: "PASS", family: selected.family, sourceBacked: true, marker: selected.marker, sourcePaths: selected.files, verification: { status: "DEFERRED", chromium: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: selected.next }, null, 2)}\n`);
fs.mkdirSync(abs("docs/status"), { recursive: true });
fs.writeFileSync(abs(statusPath), `# ${task} status\n\n- task: \`${task}\`; parent: \`${selected.parent}\`; status: \`done\`\n- source-backed implementation family: \`${selected.family}\`; marker: \`${selected.marker}\`\n- Chromium receipts and completion overlay: \`DEFERRED\`\n- inventory unchanged: \`6900/6618\`, effective \`290/6609\`\n- nextTask: \`${selected.next ?? "NONE"}\`\n`);
const planPath = `${out}/animation-render-task-plan.json`;
const plan = json(parent.artifacts.plan.path);
plan.tasks = plan.tasks.map((candidate) => candidate.id === task ? { ...candidate, status: "done", ready: false } : candidate.id === selected.next ? { ...candidate, status: "in_progress", ready: true } : { ...candidate, ready: false });
if (selected.next && !plan.tasks.some((candidate) => candidate.id === selected.next)) {
plan.tasks.push({ id: selected.next, phase: "P31", title: "authorize_resource_scene_workbench", kind: "enabling", owner: "PROGRAM", dependsOn: [task], parityId: null, implementationClass: "SOURCE_BACKED", parallelGroup: "p31-000", gate: "G1", card: `docs/tasks/${selected.next}.md`, behavior: "Authorize the next source-backed resource and scene-data implementation wave.", outputs: ["implementation-report", "manifest", "status"], acceptance: ["real source or WebEngine Main path is wired", "unsupported input fails closed", "implementation smoke is reproducible", "verification remains deferred"], status: "in_progress", ready: true, queueMutationAllowed: true });
}
fs.writeFileSync(abs(planPath), `${JSON.stringify(plan, null, 2)}\n`);
if (selected.next) fs.writeFileSync(abs(`docs/tasks/${selected.next}.md`), read(`docs/tasks/${selected.next}.md`).replace("- status: planned", "- status: in_progress"));
execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(planPath)], { cwd: root, stdio: "inherit" });
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, `| 当前任务 | \`${selected.next ?? task}\` |`).replace(/\| parent manifest \| `[^`]+` \|/u, `| parent manifest | \`tests/golden/${task}/manifest.json\` |`).replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, `| 任务卡 | [\`tasks/${selected.next ?? task}.md\`](tasks/${selected.next ?? task}.md) |`);
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", task, "--write"], { cwd: root, stdio: "inherit" });
const manifestPath = `${out}/manifest.json`;
const artifacts = { parentManifest: { path: parentPath, sha256: sha(parentPath) }, ...Object.fromEntries(selected.files.map((file) => [path.basename(file).replace(/\W+/gu, "_").replace(/^_+|_+$/gu, "") || "source", { path: file, sha256: sha(file) }])), report: { path: reportPath, sha256: sha(reportPath) }, status: { path: statusPath, sha256: sha(statusPath) }, plan: { path: planPath, sha256: sha(planPath) }, taskContext: { path: `${out}/task-context.json`, sha256: sha(`${out}/task-context.json`) } };
fs.writeFileSync(abs(manifestPath), `${JSON.stringify({ schemaVersion: 1, task, parentTask: selected.parent, operation: "IMPLEMENT_ANIMATION_RENDER_FAMILY", status: "done", enablingTask: false, parityStateChange: false, runtime: "SOURCE_BACKED_ANIMATION_RENDER_IMPLEMENTATION", artifacts, assertions: { capabilityFamily: selected.family, sourceBacked: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: selected.next }, null, 2)}\n`);
if (selected.next) execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", selected.next, "--write"], { cwd: root, stdio: "inherit" });
let next = read("nextTask.md");
next = next.replace(/\| Current task when this file was written \| `[^`]+` \|/u, `| Current task when this file was written | \`${selected.next ?? task}\` |`).replace(/\| Current task state \| `[^`]+` \|/u, `| Current task state | \`${selected.next ? "in_progress" : "done"}\` |`).replace(/\| Parent manifest \| `[^`]+` \|/u, `| Parent manifest | \`tests/golden/${task}/manifest.json\` |`).replace(/\| Current task card \| `[^`]+` \|/u, `| Current task card | \`docs/tasks/${selected.next ?? task}.md\` |`).replace(/\| Current task-context nextTask \| `[^`]+` \|/u, `| Current task-context nextTask | \`${config[selected.next]?.next ?? "NONE"}\` |`).replace(/\| Focused command \| `[^`]+` \|/u, `| Focused command | \`node tools/web/generate-wbv2-animation-render-slice.mjs --task ${selected.next ?? task} --write\` |`);
fs.writeFileSync(abs("nextTask.md"), next);
console.log(`wbv2-animation-render-slice-written task=${task} family=${selected.family} next=${selected.next ?? "NONE"} verification=DEFERRED`);