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

66 lines
11 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 parent = json("tests/golden/WBV2-P29-003/manifest.json");
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P29-004");
const smoke = "WBV2-P29-004";
const smokeOut = `tests/golden/${smoke}`;
const assets = fs.readdirSync(abs("web/dist/assets"));
const worker = assets.find((file) => /^web-engine\.worker-.*\.js$/u.test(file));
const wasm = assets.find((file) => /^web_engine-.*\.wasm$/u.test(file));
assert.ok(worker && wasm);
const smokeReport = `${smokeOut}/implementation-smoke-report.json`;
const smokeStatus = `docs/status/${smoke}.md`;
fs.mkdirSync(abs("docs/status"), { recursive: true });
fs.writeFileSync(abs(smokeReport), `${JSON.stringify({ schemaVersion: 1, task: smoke, operation: "RUN_NATIVE_DATABLOCK_IMPLEMENTATION_SMOKE", status: "PASS", build: { command: "npm --prefix web run build", exitCode: 0, worker: `web/dist/assets/${worker}`, wasm: `web/dist/assets/${wasm}` }, verification: { status: "DEFERRED", chromium: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: "WBV2-P30-000" }, null, 2)}\n`);
fs.writeFileSync(abs(smokeStatus), `# ${smoke} status\n\n- task: \`${smoke}\`; parent: \`WBV2-P29-003\`; status: \`done\`\n- native datablock implementation smoke: \`PASS\`; output includes \`${worker}\` and \`${wasm}\`\n- Chromium receipts and completion overlay: \`DEFERRED\`\n- inventory unchanged: \`6900/6618\`, effective \`290/6609\`\n- nextTask: \`WBV2-P30-000\`\n`);
const smokePlan = `${smokeOut}/native-datablock-task-plan.json`;
const plan = json(parent.artifacts.plan.path);
plan.tasks = plan.tasks.map((candidate) => ({ ...candidate, status: candidate.id === smoke ? "done" : candidate.status, ready: false }));
fs.writeFileSync(abs(smokePlan), `${JSON.stringify(plan, null, 2)}\n`);
const smokeManifest = `${smokeOut}/manifest.json`;
fs.writeFileSync(abs(smokeManifest), `${JSON.stringify({ schemaVersion: 1, task: smoke, parentTask: "WBV2-P29-003", operation: "RUN_NATIVE_DATABLOCK_IMPLEMENTATION_SMOKE", status: "done", enablingTask: true, parityStateChange: false, runtime: "VITE_BUILD_AND_SOURCE_WASM_SMOKE", artifacts: { parentManifest: { path: "tests/golden/WBV2-P29-003/manifest.json", sha256: sha("tests/golden/WBV2-P29-003/manifest.json") }, report: { path: smokeReport, sha256: sha(smokeReport) }, status: { path: smokeStatus, sha256: sha(smokeStatus) }, plan: { path: smokePlan, sha256: sha(smokePlan) }, index: { path: "web/dist/index.html", sha256: sha("web/dist/index.html") }, worker: { path: `web/dist/assets/${worker}`, sha256: sha(`web/dist/assets/${worker}`) }, wasm: { path: `web/dist/assets/${wasm}`, sha256: sha(`web/dist/assets/${wasm}`) } }, assertions: { buildExitCode: 0, sourceBackedImplementation: true, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P30-000" }, null, 2)}\n`);
const tasks = [
["WBV2-P30-000", "authorize_animation_render_workbench", "PROGRAM", smoke, "done", false, null, "Authorize the next source-backed workbench implementation wave."],
["WBV2-P30-001", "implement_animation_nla_workbench", "ANIMATION", "WBV2-P30-000", "in_progress", true, "ANIMATION.NLA_WORKBENCH", "Expose active action, FCurve interpolation and NLA stack controls through the workbench."],
["WBV2-P30-002", "implement_camera_light_world_workbench", "RENDER", "WBV2-P30-001", "planned", false, "RENDER.SCENE_PROPERTIES", "Expose camera, light and world property commands through the workbench."],
["WBV2-P30-003", "implement_nonmesh_media_workbench", "GEOMETRY", "WBV2-P30-002", "planned", false, "GEOMETRY.NON_MESH_MEDIA", "Expose font, volume, metaball and non-mesh editing controls."],
["WBV2-P30-004", "run_p30_implementation_smoke", "RELEASE", "WBV2-P30-003", "planned", false, null, "Run bounded build and startup smoke after P30 implementation."],
];
const out = "tests/golden/WBV2-P30-000";
const planPath = `${out}/animation-render-task-plan.json`;
const records = tasks.map(([id, title, owner, parentId, status, ready, parityId, behavior]) => ({ id, phase: "P30", title, kind: id.endsWith("000") || id.endsWith("004") ? "enabling" : "feature", owner, dependsOn: [parentId], parityId, implementationClass: "SOURCE_BACKED", parallelGroup: `p30-${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") }));
fs.mkdirSync(abs(out), { recursive: true });
fs.writeFileSync(abs(planPath), `${JSON.stringify({ schemaVersion: 1, planId: "BLENDER_WEB_ANIMATION_RENDER_IMPLEMENTATION_P30", status: "ACTIVE_ANIMATION_RENDER_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: records }, null, 2)}\n`);
for (const [id, title, owner, parentId, status] of tasks) {
const taskData = records.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 Main source: \`blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp\`\n- Focused protocol: \`web/protocol/web-engine.ts\`\n- Implementation entrypoint: \`node tools/web/generate-wbv2-animation-render-slice.mjs --task ${id} --write\`\n\n## 验收\n\n- real source or WebEngine Main implementation is present and connected\n- worker/client/frontend route uses typed protocol without a duplicate shim\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`);
}
const rootReport = `${out}/animation-render-root-report.json`;
const rootStatus = "docs/status/WBV2-P30-000.md";
fs.writeFileSync(abs(rootReport), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P30-000", operation: "AUTHORIZE_ANIMATION_RENDER_WORKBENCH", status: "PASS", parent: { task: smoke, manifest: smokeManifest, manifestSha256: sha(smokeManifest) }, scope: { firstTask: "WBV2-P30-001", plannedTasks: tasks.map(([id]) => id) }, verification: { status: "DEFERRED", chromium: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, nextTask: "WBV2-P30-001" }, null, 2)}\n`);
fs.writeFileSync(abs(rootStatus), "# WBV2-P30-000 status\n\n- task: `WBV2-P30-000`; parent: `WBV2-P29-004`; status: `done`\n- Animation/Render workbench implementation wave authorized\n- first task: `WBV2-P30-001`\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-P30-001`\n");
const rootManifest = `${out}/manifest.json`;
fs.writeFileSync(abs(rootManifest), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P30-000", parentTask: smoke, operation: "AUTHORIZE_ANIMATION_RENDER_WORKBENCH", status: "done", enablingTask: true, parityStateChange: false, runtime: "SOURCE_BACKED_ANIMATION_RENDER_QUEUE", artifacts: { parentManifest: { path: smokeManifest, sha256: sha(smokeManifest) }, plan: { path: planPath, sha256: sha(planPath) }, report: { path: rootReport, sha256: sha(rootReport) }, rootCard: { path: "docs/tasks/WBV2-P30-000.md", sha256: sha("docs/tasks/WBV2-P30-000.md") }, rootStatus: { path: rootStatus, sha256: sha(rootStatus) } }, assertions: { animationRenderImplementation: true, plannedTasks: tasks.length, verificationDeferred: true, completionOverlayWritten: false, inventoryTotal: 6900, effectiveCompleted: 290, effectivePending: 6609, historicalReproduction: false }, nextTask: "WBV2-P30-001" }, null, 2)}\n`);
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, "| 当前任务 | `WBV2-P30-001` |").replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P30-000/manifest.json` |").replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P30-001.md`](tasks/WBV2-P30-001.md) |");
fs.writeFileSync(abs("docs/EXECUTION_QUEUE.md"), queue);
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", smoke, "--write"], { cwd: root, stdio: "inherit" });
execFileSync(process.execPath, [abs("tools/web/check-task-context.mjs"), "--task", "WBV2-P30-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-P30-001` |").replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |").replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P30-000/manifest.json` |").replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P30-001.md` |").replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P30-002` |").replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `node tools/web/generate-wbv2-animation-render-slice.mjs --task WBV2-P30-001 --write` |");
fs.writeFileSync(abs("nextTask.md"), next);
console.log("wbv2-p30-root-written current=WBV2-P30-001 verification=DEFERRED inventory=6900 effectivePending=6609");