Files
workinf_Blender_Wasm/tools/web/generate-wbv2-module-matrix.mjs
mes123456 b78e23b16c
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
Advance WBV2 through native engine module matrix
2026-08-28 00:46:58 +08:00

61 lines
5.6 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const write = process.argv.includes("--write");
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 outputRoot = "tests/golden/WBV2-P10-003";
const matrixPath = `${outputRoot}/module-matrix.json`;
const parentPath = "tests/golden/WBV2-P10-002/manifest.json";
const inventoryPath = "tests/golden/WBV2-P0-002/parity-map.json";
const engineReceiptPath = "tests/golden/WBV2-P10-002/native-engine-receipt-report.json";
const gatePath = "tests/golden/WBV2-P9-004/feature-parity-gate-report.json";
const parent = readJson(parentPath);
assert.equal(parent.task, "WBV2-P10-002");
assert.equal(parent.status, "done");
assert.equal(parent.nextTask, "WBV2-P10-003");
for (const artifact of Object.values(parent.artifacts ?? {})) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
const inventory = readJson(inventoryPath);
const engineReceipt = readJson(engineReceiptPath);
const gate = readJson(gatePath);
assert.equal(engineReceipt.status, "PASS");
assert.equal(engineReceipt.assertions.realEngineMainMutation, true);
assert.equal(gate.status, "PASS");
const cases = [
{ id: "MESH.translateMeshVertices", family: "MESH", capabilityId: "CAP-MESH-POSITIVE-EDIT", behavior: "positive", implementationClass: "LOCAL_EXACT", expected: { mainMutation: "CHANGED", revisionDelta: 1, saveReopen: "EXACT" } },
{ id: "MESH.translateMeshVertices.stale", family: "MESH", capabilityId: "CAP-MESH-POSITIVE-EDIT", behavior: "stale_revision", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REVISION_CONFLICT" } },
{ id: "MESH.translateMeshVertices.malformed", family: "MESH", capabilityId: "CAP-MESH-POSITIVE-EDIT", behavior: "malformed_selection", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REJECTED" } },
{ id: "MODIFIER.setModifierEnabled", family: "MODIFIER", capabilityId: "CAP-MODIFIER-STATE-MUTATION", behavior: "positive", implementationClass: "LOCAL_EXACT", expected: { mainMutation: "CHANGED", revisionDelta: 1, saveReopen: "EXACT" } },
{ id: "MODIFIER.setModifierEnabled.stale", family: "MODIFIER", capabilityId: "CAP-MODIFIER-STATE-MUTATION", behavior: "stale_revision", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REVISION_CONFLICT" } },
{ id: "MODIFIER.setModifierEnabled.unknown", family: "MODIFIER", capabilityId: "CAP-MODIFIER-STATE-MUTATION", behavior: "unknown_modifier", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REJECTED" } },
{ id: "ASSET_CATALOG.appendLibraryObject", family: "ASSET_CATALOG", capabilityId: "CAP-ASSET-CATALOG-MUTATION", behavior: "positive", implementationClass: "LOCAL_EXACT", expected: { mainMutation: "CHANGED", revisionDelta: 1, saveReopen: "EXACT" } },
{ id: "ASSET_CATALOG.appendLibraryObject.stale", family: "ASSET_CATALOG", capabilityId: "CAP-ASSET-CATALOG-MUTATION", behavior: "stale_revision", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REVISION_CONFLICT" } },
{ id: "ASSET_CATALOG.appendLibraryObject.collision", family: "ASSET_CATALOG", capabilityId: "CAP-ASSET-CATALOG-MUTATION", behavior: "collision", implementationClass: "NEGATIVE_BOUNDARY", expected: { mainMutation: "UNCHANGED", revisionDelta: 0, code: "REJECTED" } },
];
const matrix = {
schemaVersion: 1,
task: "WBV2-P10-003",
operation: "CORE_MODULE_OPERATOR_MATRIX",
status: "READY",
catalog: { path: inventoryPath, sha256: sha256(inventoryPath), inventoryEntries: inventory.summary.inventoryEntries, pendingEntries: inventory.summary.pendingLegacyEntries },
source: { featureGate: gatePath, featureGateSha256: sha256(gatePath), engineReceipt: engineReceiptPath, engineReceiptSha256: sha256(engineReceiptPath) },
policy: { oneCatalogHash: true, positiveClaimsRequireMainMutation: true, negativeCasesNeverAdvanceRevision: true, unmappedInventoryExplicit: true, historicalReproduction: false },
modules: ["MESH", "MODIFIER", "ASSET_CATALOG"],
cases,
coverage: { matrixCases: cases.length, positiveCases: cases.filter((entry) => entry.behavior === "positive").length, negativeCases: cases.filter((entry) => entry.behavior !== "positive").length, inventoryEntries: inventory.summary.inventoryEntries, inventoryEntriesClaimedComplete: 0, inventoryEntriesRemainingExplicit: inventory.summary.inventoryEntries },
shards: [{ id: "core-geometry", families: ["MESH", "MODIFIER"], caseIds: cases.filter((entry) => ["MESH", "MODIFIER"].includes(entry.family)).map((entry) => entry.id) }, { id: "asset-resource", families: ["ASSET_CATALOG"], caseIds: cases.filter((entry) => entry.family === "ASSET_CATALOG").map((entry) => entry.id) }],
};
assert.equal(matrix.cases.length, 9);
if (write) {
fs.mkdirSync(absolute(outputRoot), { recursive: true });
fs.writeFileSync(absolute(matrixPath), `${JSON.stringify(matrix, null, 2)}\n`);
}
process.stdout.write(`wbv2-module-matrix-${write ? "written" : "ready"} task=WBV2-P10-003 cases=${cases.length} positive=3 negative=6 inventory=${inventory.summary.inventoryEntries} catalogSha256=${sha256(inventoryPath)}\n`);