Files
workinf_Blender_Wasm/tools/web/generate-wbv2-implementation-smoke.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

96 lines
12 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 parentPath = "tests/golden/WBV2-P25-007/manifest.json";
const parent = json(parentPath);
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P25-008");
assert.ok(fs.existsSync(abs("web/dist/index.html")));
assert.ok(fs.existsSync(abs("web/dist/assets/web-engine.worker-RtVT2Ln5.js")));
assert.ok(fs.existsSync(abs("web/dist/assets/web_engine-tuhS8OZi.wasm")));
assert.match(read("web/dist/index.html"), /<script type="module"/u);
const p25Task = "WBV2-P25-008";
const p25Out = `tests/golden/${p25Task}`;
const p25ReportPath = `${p25Out}/implementation-smoke-report.json`;
const p25StatusPath = `docs/status/${p25Task}.md`;
const p25PlanPath = `${p25Out}/implementation-task-plan.json`;
writeJson(p25ReportPath, {
schemaVersion: 1,
task: p25Task,
operation: "RUN_IMPLEMENTATION_WAVE_SMOKE",
status: "PASS",
build: { command: "npm --prefix web run build", exitCode: 0, index: "web/dist/index.html", worker: "web/dist/assets/web-engine.worker-RtVT2Ln5.js", wasm: "web/dist/assets/web_engine-tuhS8OZi.wasm" },
browserStart: { command: "npm --prefix web run dev -- --host 127.0.0.1", url: "http://127.0.0.1:5173/", httpStatus: 200, chromiumProductionVerification: "DEFERRED" },
implementation: { p25Families: ["ENGINE.COMMAND_REGISTRY", "OBJECT_OPERATIONS.CORE_SCENE", "MESH.AUTHORING", "GEOMETRY.NON_MESH", "ANIMATION.RENDER", "IO.MEDIA_STORAGE", "FRONTEND.WORKBENCH"], sourceBacked: true },
verification: { status: "DEFERRED", chromium: false, completionOverlay: false, fullHistoricalReproduction: false },
inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 },
nextTask: "WBV2-P26-000",
});
fs.mkdirSync(abs("docs/status"), { recursive: true });
fs.writeFileSync(abs(p25StatusPath), `# ${p25Task} status\n\n- task: \`${p25Task}\`; parent: \`WBV2-P25-007\`; status: \`done\`\n- implementation wave build: \`PASS\`; Vite output contains index, worker and WASM\n- browser start smoke: \`PASS\` at \`http://127.0.0.1:5173/\`; Chromium production verification remains deferred\n- P25 capability families are source-backed and connected; no completion overlay written\n- inventory unchanged: \`6900\` total, \`281\` legacy completed, \`6618\` legacy pending, \`290/6609\` effective carried forward\n- nextTask: \`WBV2-P26-000\`\n`);
const p25ParentPlan = json(parent.artifacts.plan.path);
const p25Plan = structuredClone(p25ParentPlan);
p25Plan.tasks = p25Plan.tasks.map((candidate) => candidate.id === p25Task ? { ...candidate, status: "done", ready: false } : { ...candidate, ready: false });
writeJson(p25PlanPath, p25Plan);
const p25ManifestPath = `${p25Out}/manifest.json`;
writeJson(p25ManifestPath, {
schemaVersion: 1, task: p25Task, parentTask: "WBV2-P25-007", operation: "RUN_IMPLEMENTATION_WAVE_SMOKE", status: "done", enablingTask: true, parityStateChange: false,
runtime: "VITE_BUILD_AND_BROWSER_START_SMOKE", artifacts: {
parentManifest: { path: parentPath, sha256: sha(parentPath) },
report: { path: p25ReportPath, sha256: sha(p25ReportPath) },
status: { path: p25StatusPath, sha256: sha(p25StatusPath) },
plan: { path: p25PlanPath, sha256: sha(p25PlanPath) },
index: { path: "web/dist/index.html", sha256: sha("web/dist/index.html") },
worker: { path: "web/dist/assets/web-engine.worker-RtVT2Ln5.js", sha256: sha("web/dist/assets/web-engine.worker-RtVT2Ln5.js") },
wasm: { path: "web/dist/assets/web_engine-tuhS8OZi.wasm", sha256: sha("web/dist/assets/web_engine-tuhS8OZi.wasm") },
},
assertions: { buildExitCode: 0, browserStartHttpStatus: 200, sourceBackedImplementation: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P26-000",
});
const p26Tasks = [
["WBV2-P26-000", "authorize_advanced_capability_implementation", "PROGRAM", "WBV2-P25-008", "done", false, null, "Authorize source-backed implementation for remaining guarded and unexposed capability domains."],
["WBV2-P26-001", "implement_geometry_nodes_main_writer", "GEOMETRY", "WBV2-P26-000", "in_progress", true, "GEOMETRY_NODES.MAIN_WRITER", "Persist validated Geometry Node graphs through the authoritative Main writer."],
["WBV2-P26-002", "implement_shader_graph_workbench", "SHADER", "WBV2-P26-001", "planned", false, "SHADER.GRAPH_WORKBENCH", "Expose the source-backed shader graph writer through the workbench."],
["WBV2-P26-003", "implement_simulation_physics_particle", "SIMULATION", "WBV2-P26-002", "planned", false, "SIMULATION.PHYSICS_PARTICLE", "Connect physics, particle and cache capability routes to real Main data."],
["WBV2-P26-004", "implement_render_compositor_sequencer", "RENDER", "WBV2-P26-003", "planned", false, "RENDER.COMPOSITOR_SEQUENCER", "Connect render, compositor, sequencer and media playback surfaces."],
["WBV2-P26-005", "implement_asset_library_storage", "IO", "WBV2-P26-004", "planned", false, "IO.ASSET_LIBRARY_STORAGE", "Complete library append, packed assets, OPFS and resource lifecycle paths."],
["WBV2-P26-006", "run_advanced_implementation_smoke", "RELEASE", "WBV2-P26-005", "planned", false, null, "Run a bounded build/start smoke before opening the deferred verification wave."],
];
const p26Out = "tests/golden/WBV2-P26-000";
const p26PlanPath = `${p26Out}/advanced-implementation-task-plan.json`;
const p26Plan = { schemaVersion: 1, planId: "BLENDER_WEB_ADVANCED_IMPLEMENTATION_WAVE_P26", status: "ACTIVE_ADVANCED_SOURCE_BACKED_QUEUE", authority: "user_authorized_implementation_first_execution", executionPointer: "docs/EXECUTION_QUEUE.md", runtimePolicy: { blenderSource: "blender-5.2.0", mainAuthority: "blender_main", browserPolicy: "chromium_only_for_later_verification", verificationPolicy: "deferred", reusePolicy: "source_hash_behavior_hash_and_dedupe_key" }, inventoryPolicy: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609, overlayMutation: "forbidden_during_implementation_wave" }, tasks: p26Tasks.map(([id, title, owner, parentId, status, ready, parityId, behavior]) => ({ id, phase: "P26", title, kind: id.endsWith("000") || id.endsWith("006") ? "enabling" : "feature", owner, dependsOn: [parentId], parityId, implementationClass: "SOURCE_BACKED", parallelGroup: `p26-${id.slice(-3)}`, gate: id.endsWith("000") ? "G1" : "IMPLEMENTATION", card: `docs/tasks/${id}.md`, behavior, 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, ready, queueMutationAllowed: id.endsWith("000") })) };
for (const [id, title, owner, parentId, status] of p26Tasks) {
const taskData = p26Plan.tasks.find((candidate) => candidate.id === id);
fs.writeFileSync(abs(`docs/tasks/${id}.md`), `# ${id}: ${title}\n\n- task: ${id}\n- parent: ${parentId}\n- status: ${status}\n- gap: ${taskData.parityId ?? `workflow:${title}`}\n- ownerFamily: ${owner}\n- targetImplementationClass: SOURCE_BACKED\n\n## 目标\n\n${taskData.behavior}\n\n## 输入与范围\n\n- Focused source: \`blender-5.2.0/source/blender/web_engine/web_engine_api.cpp\`\n- Focused protocol: \`web/protocol/web-engine.ts\`\n- Implementation entrypoint: \`node tools/web/generate-wbv2-advanced-slice.mjs --task ${id} --write\`\n\n## 验收\n\n- real source or WebEngine Main implementation is present and connected\n- malformed, unsupported, hash-drift or false-completion input fails closed\n- implementation smoke is reproducible; Chromium receipts, undo/redo, save/reopen and deterministic verification remain deferred\n- \`node tools/web/check-task-context.mjs --task ${id} --write\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/${id}/\`\n- Status: \`docs/status/${id}.md\`\n- Manifest: \`tests/golden/${id}/manifest.json\`\n- Rollback: restore ${parentId} as queue parent and leave the slice in_progress.\n`);
}
writeJson(p26PlanPath, p26Plan);
const p26ReportPath = `${p26Out}/advanced-implementation-root-report.json`;
writeJson(p26ReportPath, { schemaVersion: 1, task: "WBV2-P26-000", operation: "AUTHORIZE_ADVANCED_CAPABILITY_IMPLEMENTATION", status: "PASS", parent: { task: p25Task, manifest: p25ManifestPath, manifestSha256: sha(p25ManifestPath) }, scope: { firstTask: "WBV2-P26-001", plannedTasks: p26Tasks.map(([id]) => id), capabilityFamilies: p26Tasks.filter(([, , , , , , parityId]) => parityId).map(([, , , , , , parityId]) => parityId) }, verification: { status: "DEFERRED", chromium: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: "WBV2-P26-001" });
const p26StatusPath = "docs/status/WBV2-P26-000.md";
fs.writeFileSync(abs(p26StatusPath), "# WBV2-P26-000 status\n\n- task: `WBV2-P26-000`; parent: `WBV2-P25-008`; status: `done`\n- advanced guarded/unexposed capability implementation queue authorized\n- first task: `WBV2-P26-001` Geometry Nodes Main writer\n- verification receipts and completion overlays: `DEFERRED`\n- inventory unchanged: `6900` total, `281` legacy completed, `6618` legacy pending, `290/6609` effective carried forward\n- nextTask: `WBV2-P26-001`\n");
const p26ManifestPath = `${p26Out}/manifest.json`;
writeJson(p26ManifestPath, { schemaVersion: 1, task: "WBV2-P26-000", parentTask: p25Task, operation: "AUTHORIZE_ADVANCED_CAPABILITY_IMPLEMENTATION", status: "done", enablingTask: true, parityStateChange: false, runtime: "SOURCE_BACKED_ADVANCED_IMPLEMENTATION_QUEUE", artifacts: { parentManifest: { path: p25ManifestPath, sha256: sha(p25ManifestPath) }, plan: { path: p26PlanPath, sha256: sha(p26PlanPath) }, report: { path: p26ReportPath, sha256: sha(p26ReportPath) }, rootCard: { path: "docs/tasks/WBV2-P26-000.md", sha256: sha("docs/tasks/WBV2-P26-000.md") }, rootStatus: { path: p26StatusPath, sha256: sha(p26StatusPath) } }, assertions: { advancedImplementationWave: true, plannedTasks: 7, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P26-001" });
execFileSync(process.execPath, [abs("tools/web/generate-v2-task-index.mjs"), "--plan-path", abs(p26PlanPath)], { cwd: root, stdio: "inherit" });
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P26-001` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P26-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P26-001.md`](tasks/WBV2-P26-001.md) |");
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", p25Task, "--write"], { cwd: root, stdio: "inherit" });
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P26-001", "--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 | `WBV2-P26-001` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P26-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P26-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P26-002` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-advanced-slice.mjs --task WBV2-P26-001 --write` |");
fs.writeFileSync(abs("nextTask.md"), next);
console.log("wbv2-implementation-smoke-written p25=complete p26=authorized current=WBV2-P26-001 verification=DEFERRED");