Files
workinf_Blender_Wasm/tools/web/generate-wbv2-module-expansion-root.mjs
mes123456 f18f80d0b9
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
Continue WBV2 module parity through P11
2026-08-28 05:50:14 +08:00

90 lines
18 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 absolute = (file) => path.join(root, file);
const read = (file) => fs.readFileSync(absolute(file), "utf8");
const readJson = (file) => JSON.parse(read(file));
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(absolute(file))).digest("hex");
const p10ManifestPath = "tests/golden/WBV2-P10-003/manifest.json";
const p10ReportPath = "tests/golden/WBV2-P10-003/module-matrix-receipt-report.json";
const p10StatusPath = "docs/status/WBV2-P10-003.md";
const outputRoot = "tests/golden/WBV2-P11-000";
const planPath = `${outputRoot}/module-expansion-task-plan.json`;
const reportPath = `${outputRoot}/module-expansion-root-report.json`;
const manifestPath = `${outputRoot}/manifest.json`;
const rootStatusPath = "docs/status/WBV2-P11-000.md";
const p10 = readJson(p10ManifestPath);
const p10Report = readJson(p10ReportPath);
assert.equal(p10.task, "WBV2-P10-003");
assert.equal(p10.status, "done");
assert.ok(p10.nextTask === null || p10.nextTask === "WBV2-P11-000");
assert.equal(p10Report.task, "WBV2-P10-003");
assert.equal(p10Report.status, "PASS");
assert.equal(p10Report.assertions.historicalReproduction, false);
for (const artifact of Object.values(p10.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
const basePlan = readJson("tests/golden/WBV2-P10-003/native-parity-task-plan.json");
assert.equal(basePlan.planId, "BLENDER_WEB_PARITY_V2_NATIVE_ENGINE_EPOCH_1");
const tasks = basePlan.tasks.map((task) => ({ ...task, ready: false, status: task.id === "WBV2-P10-003" ? "done" : task.status }));
const p11 = [
{ id: "WBV2-P11-000", phase: "P11", title: "authorize_module_expansion_continuation", kind: "enabling", owner: "PROGRAM", dependsOn: ["WBV2-P10-003"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p11-governance", gate: "G7", card: "docs/tasks/WBV2-P11-000.md", behavior: "Authorize deeper module production after real native/WASM engine binding and the first aggregate matrix.", outputs: ["continuation root", "module expansion plan", "scope limits"], acceptance: ["P10 evidence remains hash-bound", "one expansion task is active", "full historical reproduction remains false"], status: "done", ready: false, queueMutationAllowed: true },
{ id: "WBV2-P11-001", phase: "P11", title: "mesh_topology_operation_family", kind: "feature", owner: "MESH", dependsOn: ["WBV2-P11-000"], parityId: "MESH.EDIT_TOPOLOGY_FAMILY", implementationClass: "LOCAL_EXACT", parallelGroup: "p11-mesh", gate: "G7", card: "docs/tasks/WBV2-P11-001.md", behavior: "Execute merge, dissolve, extrude, inset, bevel, and loop-cut through the real Blender WASM Main and preserve each result through save/reopen.", outputs: ["topology receipt", "negative matrix", "manifest"], acceptance: ["six mesh operations mutate Main", "revision increments exactly once", "save/reopen preserves topology counts", "invalid selection and incompatible configuration fail closed"], status: "in_progress", ready: true, queueMutationAllowed: false },
{ id: "WBV2-P11-002", phase: "P11", title: "modifier_parameter_apply_family", kind: "feature", owner: "MODIFIER", dependsOn: ["WBV2-P11-001"], parityId: "MODIFIER.PARAMETER_APPLY_FAMILY", implementationClass: "LOCAL_EXACT", parallelGroup: "p11-modifier", gate: "G7", card: "docs/tasks/WBV2-P11-002.md", behavior: "Extend the real Modifier Main path from enable/disable to bounded parameter and apply transactions.", outputs: ["modifier parameter receipt", "negative matrix", "manifest"], acceptance: ["parameter mutation is native/WASM bound", "apply result is evaluated", "save/reopen is exact", "dependency and stale inputs fail closed"], status: "planned", ready: false, queueMutationAllowed: false },
{ id: "WBV2-P11-003", phase: "P11", title: "asset_link_override_reload_family", kind: "feature", owner: "ASSET", dependsOn: ["WBV2-P11-002"], parityId: "ASSET.LINK_OVERRIDE_RELOAD_FAMILY", implementationClass: "LOCAL_EXACT", parallelGroup: "p11-asset", gate: "G7", card: "docs/tasks/WBV2-P11-003.md", behavior: "Extend the real Asset Main path from append to link, override, reload, and missing-library boundaries.", outputs: ["asset ownership receipt", "negative matrix", "manifest"], acceptance: ["source ownership is preserved", "override is local and hash-bound", "reload revision is checked", "missing source remains explicit"], status: "planned", ready: false, queueMutationAllowed: false },
{ id: "WBV2-P11-004", phase: "P11", title: "recompute_engine_module_gate", kind: "enabling", owner: "RELEASE", dependsOn: ["WBV2-P11-003"], parityId: null, implementationClass: "LOCAL_BOUNDED", parallelGroup: "p11-release", gate: "G8", card: "docs/tasks/WBV2-P11-004.md", behavior: "Recompute engine-bound module parity from P10 and P11 receipts without claiming whole-inventory completion.", outputs: ["engine module gate", "limited release declaration", "manifest"], acceptance: ["only engine-bound claims are emitted", "inventory remainder is explicit", "provenance epoch 2 remains authorized rebaseline only", "full historical reproduction remains false"], status: "planned", ready: false, queueMutationAllowed: false },
];
const plan = { ...basePlan, planId: "BLENDER_WEB_PARITY_V2_MODULE_EXPANSION_EPOCH_1", status: "ACTIVE_MODULE_EXPANSION_QUEUE", authority: "queue_reactivated_after_p10_engine_matrix", recoveryRoot: "WBV2-P11-000", parentRecoveryPlan: { path: "tests/golden/WBV2-P10-003/native-parity-task-plan.json", sha256: sha256("tests/golden/WBV2-P10-003/native-parity-task-plan.json") }, tasks: [...tasks, ...p11] };
fs.mkdirSync(absolute(outputRoot), { recursive: true });
fs.writeFileSync(absolute(planPath), `${JSON.stringify(plan, null, 2)}\n`);
const report = { schemaVersion: 1, task: "WBV2-P11-000", operation: "AUTHORIZE_MODULE_EXPANSION_CONTINUATION", status: "PASS", parent: { task: p10.task, manifest: p10ManifestPath, manifestSha256: sha256(p10ManifestPath), previousDecision: p10Report.operation, fullHistoricalReproduction: p10Report.assertions.historicalReproduction }, continuation: { root: "WBV2-P11-000", firstTask: "WBV2-P11-001", plannedTasks: 5, scope: ["MESH_TOPOLOGY", "MODIFIER_PARAMETER_APPLY", "ASSET_LINK_OVERRIDE_RELOAD", "ENGINE_MODULE_GATE"], browser: "chromium", nativeEngineAlreadyBound: true }, policy: { historicalEvidencePreserved: true, authorizedRebaselineOnly: true, engineClaimsEvidenceBound: true, fullHistoricalReproduction: false, inventoryRemainderExplicit: true }, nextTask: "WBV2-P11-001" };
fs.writeFileSync(absolute(reportPath), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(absolute("docs/tasks/WBV2-P11-000.md"), `# WBV2-P11-000: module expansion continuation root\n\n- task: WBV2-P11-000\n- parent: WBV2-P10-003\n- status: done\n- gap: workflow:authorize_module_expansion_continuation\n- ownerFamily: PROGRAM\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nAuthorize module expansion after P10 proved the compiled native Blender/WASM engine path. P11 only advances engine-bound Mesh, Modifier, and Asset behavior; it does not claim complete Blender parity or historical byte reproduction.\n\n## 验收\n\n- \`node tools/web/generate-wbv2-module-expansion-root.mjs\`\n- \`node tools/web/check-execution-control-plane.mjs\`\n- \`node tools/web/check-v2-task-index.mjs\`\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P11-000/\`\n- Manifest: \`tests/golden/WBV2-P11-000/manifest.json\`\n- Rollback: restore P10-003 as queue parent without rewriting P7-P10 evidence.\n`);
fs.writeFileSync(absolute("docs/tasks/WBV2-P11-001.md"), `# WBV2-P11-001: Mesh topology operation family\n\n- task: WBV2-P11-001\n- parent: WBV2-P11-000\n- status: in_progress\n- gap: workflow:mesh_topology_operation_family\n- ownerFamily: MESH\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nExecute merge, dissolve, extrude, inset, bevel, and loop-cut through the real compiled WebEngine WASM Main and preserve each result through save/reopen.\n\n## 输入与范围\n\n- Mesh fixture: \`tests/files/web/generated/WBV2-P2-003-MESH.EDIT_CORE.blend\`\n- Desktop oracle: \`tests/golden/WBV2-P2-003/mesh-edit-desktop-report.json\`\n- WASM source report: \`tests/golden/WBV2-P2-003/mesh-edit-report.json\`\n- Client: \`web/app/src/engine-client/WebEngineClient.ts\`\n- Test: \`web/tests/e2e/wbv2-mesh-topology-production.spec.ts\`\n\n## 验收\n\n- \`npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-mesh-topology-production.spec.ts\`\n- \`node tools/web/generate-wbv2-mesh-topology-receipt.mjs --write\`\n- \`node tools/web/check-task-context.mjs --task WBV2-P11-001 --write\`\n\nMalformed or unsupported operation, invalid selection, stale revision, non-Chromium execution, non-exact save/reopen, or missing Main mutation must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P11-001/\`\n- Status: \`docs/status/WBV2-P11-001.md\`\n- Manifest: \`tests/golden/WBV2-P11-001/manifest.json\`\n- Rollback: restore P11-000 as queue parent without modifying P10 evidence.\n`);
fs.writeFileSync(absolute("docs/tasks/WBV2-P11-002.md"), `# WBV2-P11-002: Modifier parameter and apply family\n\n- task: WBV2-P11-002\n- parent: WBV2-P11-001\n- status: planned\n- gap: workflow:modifier_parameter_apply_family\n- ownerFamily: MODIFIER\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nExtend the real Modifier Main path from enable/disable to bounded parameter and apply transactions.\n\n## 输入与范围\n\n- Modifier fixture: \`tests/files/web/generated/WBV2-P4-001-MODIFIER.DECLARED_SLICES.blend\`\n- Existing native receipt: \`tests/golden/WBV2-P10-002/native-engine-receipt-report.json\`\n- Modifier protocol: \`blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp\`\n\n## 验收\n\n- \`npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-modifier-parameter-production.spec.ts\`\n- \`node tools/web/generate-wbv2-modifier-parameter-receipt.mjs --write\`\n- \`node tools/web/check-task-context.mjs --task WBV2-P11-002 --write\`\n\nMalformed, unsupported modifier, stale revision, failed apply, non-exact save/reopen, or missing evaluated Main mutation must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P11-002/\`\n- Manifest: \`tests/golden/WBV2-P11-002/manifest.json\`\n- Rollback: restore P11-001 as queue parent without modifying Mesh evidence.\n`);
fs.writeFileSync(absolute("docs/tasks/WBV2-P11-003.md"), `# WBV2-P11-003: Asset link, override, and reload family\n\n- task: WBV2-P11-003\n- parent: WBV2-P11-002\n- status: planned\n- gap: workflow:asset_link_override_reload_family\n- ownerFamily: ASSET\n- targetImplementationClass: LOCAL_EXACT\n\n## 目标\n\nExtend the real Asset Main path from append to link, local override, reload, and missing-library boundaries.\n\n## 输入与范围\n\n- Asset fixture: \`tests/files/web/generated/WBV2-P3-005-ASSET.LIBRARY_OPERATIONS.blend\`\n- Source library: \`tests/files/web/generated/WBV2P3005Library.blend\`\n- Existing append receipt: \`tests/golden/WBV2-P10-002/native-engine-receipt-report.json\`\n\n## 验收\n\n- \`npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-asset-link-override-production.spec.ts\`\n- \`node tools/web/generate-wbv2-asset-link-override-receipt.mjs --write\`\n- \`node tools/web/check-task-context.mjs --task WBV2-P11-003 --write\`\n\nMalformed binding, stale source revision, ownership violation, missing resource, non-Chromium execution, or non-exact save/reopen must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P11-003/\`\n- Status: \`docs/status/WBV2-P11-003.md\`\n- Manifest: \`tests/golden/WBV2-P11-003/manifest.json\`\n- Rollback: restore P11-002 as queue parent without modifying Mesh or Modifier evidence.\n`);
fs.writeFileSync(absolute("docs/tasks/WBV2-P11-004.md"), `# WBV2-P11-004: engine module parity gate\n\n- task: WBV2-P11-004\n- parent: WBV2-P11-003\n- status: planned\n- gap: workflow:recompute_engine_module_gate\n- ownerFamily: RELEASE\n- targetImplementationClass: LOCAL_BOUNDED\n\n## 目标\n\nRecompute engine-bound module claims from P10 and P11 receipts without claiming whole-inventory completion.\n\n## 输入与范围\n\n- P10 engine receipt: \`tests/golden/WBV2-P10-002/native-engine-receipt-report.json\`\n- P10 module matrix: \`tests/golden/WBV2-P10-003/module-matrix-receipt-report.json\`\n- P11 Mesh/Modifier/Asset receipts\n- Provenance approval: \`docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json\`\n\n## 验收\n\n- \`node tools/web/generate-wbv2-engine-module-gate.mjs --write\`\n- \`node tools/web/check-task-context.mjs --task WBV2-P11-004 --write\`\n\nMissing receipt, hash drift, unsupported browser, false inventory completion, false historical reproduction, or undeclared capability claim must keep in_progress and must not advance nextTask.\n\n## 交付与回滚\n\n- Reports: \`tests/golden/WBV2-P11-004/\`\n- Status: \`docs/status/WBV2-P11-004.md\`\n- Manifest: \`tests/golden/WBV2-P11-004/manifest.json\`\n- Rollback: restore P11-003 as queue parent without modifying engine receipts.\n`);
fs.writeFileSync(absolute(rootStatusPath), `# WBV2-P11-000 status\n\n- task: \`WBV2-P11-000\`; parent: \`WBV2-P10-003\`; status: \`done\`\n- nextTask: \`WBV2-P11-001\`\n\nModule expansion is authorized after P10 bound the compiled Blender native/WASM engine. P11 remains evidence-bound, Chromium-only, and explicit about the inventory remainder and authorized provenance baseline.\n`);
// Add an authorized continuation to the terminal P10 manifest without changing
// its completed matrix evidence or historical classification.
p10.nextTask = "WBV2-P11-000";
p10.continuation = { authorized: true, root: "WBV2-P11-000", scope: "MODULE_EXPANSION" };
p10Report.nextTask = "WBV2-P11-000";
p10Report.policy = { ...(p10Report.policy ?? {}), terminalQueuePointer: false, authorizedContinuation: "WBV2-P11-000" };
fs.writeFileSync(absolute(p10ReportPath), `${JSON.stringify(p10Report, null, 2)}\n`);
const currentP10Status = read(p10StatusPath).trim();
fs.writeFileSync(absolute(p10StatusPath), currentP10Status.includes("authorized continuation: `WBV2-P11-000`") ? `${currentP10Status}\n` : `${currentP10Status}\n- authorized continuation: \`WBV2-P11-000\`\n\nModule expansion may continue under a new manifest root. This does not change the P10 evidence or the authorized-rebaseline-only release scope.\n`);
fs.writeFileSync(absolute(p10ManifestPath), `${JSON.stringify(p10, null, 2)}\n`);
execFileSync(process.execPath, [absolute("tools/web/check-task-context.mjs"), "--task", "WBV2-P10-003", "--write"], { cwd: root, stdio: "pipe" });
p10.artifacts = Object.fromEntries(Object.entries(p10.artifacts).map(([name, artifact]) => [name, { ...artifact, sha256: sha256(artifact.path) }]));
fs.writeFileSync(absolute(p10ManifestPath), `${JSON.stringify(p10, null, 2)}\n`);
const artifactPaths = { parentManifest: p10ManifestPath, parentReport: p10ReportPath, approval: "docs/status/M12-PROVENANCE-EPOCH-2-APPROVAL.json", plan: planPath, report: reportPath, rootCard: "docs/tasks/WBV2-P11-000.md", rootStatus: rootStatusPath, activeCard: "docs/tasks/WBV2-P11-001.md" };
const artifacts = Object.fromEntries(Object.entries(artifactPaths).map(([name, file]) => [name, { path: file, sha256: sha256(file) }]));
const manifest = { schemaVersion: 1, task: "WBV2-P11-000", parentTask: "WBV2-P10-003", operation: "AUTHORIZE_MODULE_EXPANSION_CONTINUATION", status: "done", enablingTask: true, parityStateChange: false, artifacts, assertions: { p10EvidencePreserved: true, nativeEngineAlreadyBound: true, moduleExpansionScope: ["MESH_TOPOLOGY", "MODIFIER_PARAMETER_APPLY", "ASSET_LINK_OVERRIDE_RELOAD"], authorizedRebaselineOnly: true, fullHistoricalReproduction: false }, nextTask: "WBV2-P11-001" };
fs.writeFileSync(absolute(manifestPath), `${JSON.stringify(manifest, null, 2)}\n`);
execFileSync(process.execPath, [absolute("tools/web/generate-v2-task-index.mjs"), "--plan-path", absolute(planPath)], { cwd: root, stdio: "inherit" });
let queue = read("docs/EXECUTION_QUEUE.md");
queue = queue.replace(/\| 当前任务 \| `[^`]+` \|/u, "| 当前任务 | `WBV2-P11-001` |")
.replace(/\| parent manifest \| `[^`]+` \|/u, "| parent manifest | `tests/golden/WBV2-P11-000/manifest.json` |")
.replace(/\| 任务卡 \| \[[^\]]+\]\([^\)]+\) \|/u, "| 任务卡 | [`tasks/WBV2-P11-001.md`](tasks/WBV2-P11-001.md) |");
fs.writeFileSync(absolute("docs/EXECUTION_QUEUE.md"), queue);
// Keep the human-facing continuation snapshot aligned with the authoritative
// queue; the queue and parent manifest remain the machine sources of truth.
let nextTaskFile = read("nextTask.md");
nextTaskFile = nextTaskFile.replace(/\| Current task when this file was written \| `[^`]+` \|/u, "| Current task when this file was written | `WBV2-P11-001` |")
.replace(/\| Current task state \| `[^`]+` \|/u, "| Current task state | `in_progress` |")
.replace(/\| Parent manifest \| `[^`]+` \|/u, "| Parent manifest | `tests/golden/WBV2-P11-000/manifest.json` |")
.replace(/\| Current task card \| `[^`]+` \|/u, "| Current task card | `docs/tasks/WBV2-P11-001.md` |")
.replace(/\| Current task-context nextTask \| `[^`]+` \|/u, "| Current task-context nextTask | `WBV2-P11-002` |")
.replace(/\| Focused command \| `[^`]+` \|/u, "| Focused command | `npm --prefix web run test:e2e -- --workers=1 tests/e2e/wbv2-mesh-topology-production.spec.ts` |");
fs.writeFileSync(absolute("nextTask.md"), nextTaskFile);
process.stdout.write("wbv2-module-expansion-root-ok root=WBV2-P11-000 next=WBV2-P11-001 scope=MESH_TOPOLOGY,MODIFIER_PARAMETER_APPLY,ASSET_LINK_OVERRIDE_RELOAD\n");