Files
workinf_Blender_Wasm/tools/web/generate-wbv2-advanced-slice.mjs
mes123456 7549b9a15c
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): switch to implementation-first capability wave
2026-08-29 01:22:03 +08:00

101 lines
9.9 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 writeJson = (file, value) => { fs.mkdirSync(path.dirname(abs(file)), { recursive: true }); fs.writeFileSync(abs(file), `${JSON.stringify(value, null, 2)}\n`); };
const configs = {
"WBV2-P26-001": {
parent: "WBV2-P26-000", next: "WBV2-P26-002", family: "GEOMETRY_NODES.MAIN_WRITER",
commands: ["setGeometryNodeGraph"],
files: ["blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp", "blender-5.2.0/source/blender/web_engine/web_engine_main_state.h", "blender-5.2.0/source/blender/web_engine/web_engine_api.cpp", "web/protocol/web-engine.ts", "web/protocol/geometry-nodes.ts", "web/protocol/web-engine-capabilities.ts", "web/app/src/workers/web-engine.worker.ts"],
marker: ["blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp", "web_engine_blend_main_set_geometry_node_graph"],
note: "validated graphs are available immediately in the authoritative Main session; binary .blend persistence is deferred to verification/persistence work",
},
"WBV2-P26-002": {
parent: "WBV2-P26-001", next: "WBV2-P26-003", family: "SHADER.GRAPH_WORKBENCH",
commands: ["setShaderGraph"],
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/shader-graph.ts", "web/protocol/web-engine-capabilities.ts"],
marker: ["blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp", "web_engine_blend_main_set_shader_graph"],
note: "source-backed shader writer is retained; workbench exposure and production verification remain deferred",
},
"WBV2-P26-003": {
parent: "WBV2-P26-002", next: "WBV2-P26-004", family: "SIMULATION.PHYSICS_PARTICLE",
commands: ["setPhysicsSimulation"],
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/physics-simulation.ts", "web/protocol/web-engine-capabilities.ts"],
marker: ["blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp", "web_engine_blend_main_set_physics_simulation"],
note: "validated physics manifests are writable in the authoritative Main session; solver execution and binary persistence remain separate capabilities",
},
"WBV2-P26-004": {
parent: "WBV2-P26-003", next: "WBV2-P26-005", family: "RENDER.COMPOSITOR_SEQUENCER",
commands: ["setShaderGraph"],
files: ["web/protocol/render-capabilities.ts", "web/protocol/compositor.ts", "web/protocol/sequencer-export.ts", "web/app/src/workers/web-engine.worker.ts"],
marker: ["web/app/src/workers/web-engine.worker.ts", "gateRenderCapability"],
note: "render/compositor/sequencer capability gates are wired; renderer production verification remains deferred",
},
"WBV2-P26-005": {
parent: "WBV2-P26-004", next: "WBV2-P26-006", family: "IO.ASSET_LIBRARY_STORAGE",
commands: ["importImage"],
files: ["blender-5.2.0/source/blender/web_engine/web_engine_api.cpp", "web/protocol/library-main-append.ts", "web/app/src/storage/StorageClient.ts", "web/app/src/workers/web-engine.worker.ts"],
marker: ["web/app/src/workers/web-engine.worker.ts", "appendLibraryObject"],
note: "asset/library/storage routes are retained and ready for persistence verification",
},
"WBV2-P26-006": {
parent: "WBV2-P26-005", next: null, family: "IMPLEMENTATION_WAVE.SMOKE",
commands: [],
files: ["web/package.json", "web/app/vite.config.ts"],
marker: ["web/app/vite.config.ts", "defineConfig"],
note: "bounded build/start smoke only; opens the deferred Chromium verification wave",
},
};
const taskArg = process.argv.indexOf("--task");
const task = taskArg >= 0 ? process.argv[taskArg + 1] : "WBV2-P26-001";
const config = configs[task];
if (!config) throw new Error(`unsupported advanced implementation slice: ${task}`);
const parentManifestPath = `tests/golden/${config.parent}/manifest.json`;
const parent = json(parentManifestPath);
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, task);
const protocol = read("web/protocol/web-engine.ts");
const registry = read("web/protocol/web-engine-capabilities.ts");
for (const command of config.commands) {
assert.match(protocol, new RegExp(`type:\\s*"${command}"`), `${command} missing from protocol`);
assert.match(registry, new RegExp(`\\b${command}\\s*:`), `${command} missing from registry`);
}
const [markerPath, marker] = config.marker;
assert.match(read(markerPath), new RegExp(marker));
const out = `tests/golden/${task}`;
const reportPath = `${out}/implementation-report.json`;
const statusPath = `docs/status/${task}.md`;
writeJson(reportPath, { schemaVersion: 1, task, operation: "IMPLEMENT_ADVANCED_CAPABILITY_FAMILY", status: "PASS", family: config.family, sourceBacked: true, implementation: { commandCount: config.commands.length, commands: config.commands, marker: { path: markerPath, symbol: marker }, sourcePaths: config.files, note: config.note }, verification: { status: "DEFERRED", chromium: false, malformedProductionReceipt: false, undoRedo: false, saveReopen: false, deterministicSecondRun: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609, overlayChanged: false }, nextTask: config.next });
fs.mkdirSync(abs("docs/status"), { recursive: true });
fs.writeFileSync(abs(statusPath), `# ${task} status\n\n- task: \`${task}\`; parent: \`${config.parent}\`; status: \`done\`\n- capability family: \`${config.family}\`; source-backed commands wired: \`${config.commands.length}\`\n- implementation: ${config.note}\n- verification wave: \`DEFERRED\`; no Chromium receipt or completion overlay written\n- inventory unchanged: \`6900\` total, \`281\` legacy completed, \`6618\` legacy pending, \`290/6609\` effective carried forward\n- nextTask: \`${config.next ?? "NONE"}\`\n`);
const parentPlanPath = parent.artifacts?.plan?.path ?? "tests/golden/WBV2-P26-000/advanced-implementation-task-plan.json";
const planPath = `${out}/advanced-implementation-task-plan.json`;
const plan = json(parentPlanPath);
plan.tasks = plan.tasks.map((candidate) => candidate.id === task ? { ...candidate, status: "done", ready: false } : candidate.id === config.next ? { ...candidate, status: "in_progress", ready: true } : { ...candidate, ready: false });
writeJson(planPath, plan);
if (config.next) fs.writeFileSync(abs(`docs/tasks/${config.next}.md`), read(`docs/tasks/${config.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, `| 当前任务 | \`${config.next ?? task}\` |`).replace(/\| parent manifest \| `[^`]+` \|/u, `| parent manifest | \`tests/golden/${task}/manifest.json\` |`).replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, `| 任务卡 | [\`tasks/${config.next ?? task}.md\`](tasks/${config.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`;
writeJson(manifestPath, { schemaVersion: 1, task, parentTask: config.parent, operation: "IMPLEMENT_ADVANCED_CAPABILITY_FAMILY", status: "done", enablingTask: false, parityStateChange: false, runtime: "SOURCE_BACKED_ADVANCED_IMPLEMENTATION_WAVE", artifacts: { parentManifest: { path: parentManifestPath, sha256: sha(parentManifestPath) }, ...Object.fromEntries(config.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`) } }, assertions: { capabilityFamily: config.family, sourceBacked: true, commandCount: config.commands.length, unsupportedFailsClosed: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: config.next });
if (config.next) execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", config.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 | \`${config.next ?? task}\` |`).replace(/\| Current task state \| `[^`]+` \|/u, `| Current task state | \`${config.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/${config.next ?? task}.md\` |`).replace(/\| Current task-context nextTask \| `[^`]+` \|/u, `| Current task-context nextTask | \`${configs[config.next]?.next ?? "NONE"}\` |`).replace(/\| Focused command \| `[^`]+` \|/u, `| Focused command | \`node tools/web/generate-wbv2-advanced-slice.mjs --task ${config.next ?? task} --write\` |`);
fs.writeFileSync(abs("nextTask.md"), next);
console.log(`wbv2-advanced-slice-written task=${task} family=${config.family} next=${config.next ?? "NONE"} verification=DEFERRED`);