71 lines
4.5 KiB
JavaScript
71 lines
4.5 KiB
JavaScript
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 abs = (file) => path.join(root, file);
|
|
const readJson = (file) => JSON.parse(fs.readFileSync(abs(file), "utf8"));
|
|
const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex");
|
|
const inventoryPath = "tests/golden/WBV2-P0-002/parity-map.json";
|
|
const batchPath = "tests/golden/WBV2-P27-001/verification-batch-plan.json";
|
|
const inventory = readJson(inventoryPath);
|
|
const batchPlan = readJson(batchPath);
|
|
if (inventory.summary.inventoryEntries !== 6900 || batchPlan.batching.pendingRows !== 6609 || batchPlan.batching.batchCount !== 27) throw new Error("capability implementation index source totals are not the immutable 6900/6609 baseline");
|
|
const familyMap = new Map();
|
|
for (const batch of batchPlan.batching.batches) {
|
|
const entry = familyMap.get(batch.capabilityId) ?? { capabilityId: batch.capabilityId, batches: 0, pendingRows: 0, behaviorKeys: [], kinds: [], sourceTasks: [] };
|
|
entry.batches += 1;
|
|
entry.pendingRows += batch.count;
|
|
entry.behaviorKeys.push(batch.dedupe.behaviorKey);
|
|
entry.kinds.push(batch.kind);
|
|
entry.sourceTasks.push(...batch.sourceTasks);
|
|
familyMap.set(batch.capabilityId, entry);
|
|
}
|
|
const sourceMarkers = [
|
|
["DNA", "web_engine_blend_main_open"],
|
|
["SCENE-GRAPH", "web_engine_blend_main_set_parent"],
|
|
["OBJECT", "web_engine_blend_main_set_transform"],
|
|
["MESH", "web_engine_blend_main_mesh_edit"],
|
|
["MATERIAL", "web_engine_blend_main_set_material_principled"],
|
|
["GEOMETRY", "web_engine_blend_main_set_curve_control_points"],
|
|
["FONT", "web_engine_blend_main_set_font_body"],
|
|
["AUDIO", "web_engine_blend_main_set_sound_properties"],
|
|
["PARTICLE", "web_engine_blend_main_set_particle_settings"],
|
|
["TEXTURE", "web_engine_blend_main_set_texture_properties"],
|
|
["GEOMETRY_NODES", "web_engine_blend_main_set_geometry_node_graph"],
|
|
["NODES", "web_engine_blend_main_set_geometry_node_graph"],
|
|
["SHADER", "web_engine_blend_main_set_shader_graph"],
|
|
["SIMULATION", "web_engine_blend_main_set_physics_simulation"],
|
|
["MEDIA", "web_engine_blend_main_import_image"],
|
|
["RIG", "web_engine_blend_main_insert_keyframe"],
|
|
["SCULPT", "web_engine_blend_main_sculpt_stroke"],
|
|
["OTHER-OPERATOR", "web_engine_blend_main_set_frame"],
|
|
];
|
|
const sourceFiles = [
|
|
"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/web-engine.ts",
|
|
"web/protocol/web-engine-capabilities.ts",
|
|
"web/app/src/workers/web-engine.worker.ts",
|
|
];
|
|
const sourceText = sourceFiles.map((file) => fs.readFileSync(abs(file), "utf8")).join("\n");
|
|
const capabilityFamilies = [...familyMap.values()].map((family) => {
|
|
const marker = sourceMarkers.find(([name]) => family.capabilityId.includes(name));
|
|
return { ...family, behaviorKeys: [...new Set(family.behaviorKeys)].sort(), kinds: [...new Set(family.kinds)].sort(), sourceTasks: [...new Set(family.sourceTasks)].sort(), sourceMarker: marker?.[1] ?? null, sourceBacked: marker ? sourceText.includes(marker[1]) : false };
|
|
}).sort((left, right) => left.capabilityId.localeCompare(right.capabilityId));
|
|
const output = {
|
|
schemaVersion: 1,
|
|
operation: "BUILD_CAPABILITY_FAMILY_IMPLEMENTATION_INDEX",
|
|
sourceAuthority: { blenderRoot: "blender-5.2.0", mainAuthority: "blender_main", sourceFiles: Object.fromEntries(sourceFiles.map((file) => [file, sha(file)])) },
|
|
inventory: { path: inventoryPath, sha256: sha(inventoryPath), total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 },
|
|
batching: { path: batchPath, sha256: sha(batchPath), strategy: batchPlan.batching.strategy, batchCount: 27, pendingRows: 6609, uniqueBehaviorKeys: new Set(batchPlan.batching.batches.map((batch) => batch.dedupe.behaviorKey)).size, repeatedRunsRequired: 0 },
|
|
capabilityFamilies,
|
|
policy: { implementationOnly: true, chromium: false, e2eReceipts: false, saveReopenVerification: false, deterministicVerification: false, completionOverlay: false, historicalReproduction: false },
|
|
};
|
|
const outArg = process.argv.indexOf("--out");
|
|
const out = outArg >= 0 ? process.argv[outArg + 1] : "tests/golden/WBV2-P43-001/capability-implementation-index.json";
|
|
fs.mkdirSync(path.dirname(abs(out)), { recursive: true });
|
|
fs.writeFileSync(abs(out), `${JSON.stringify(output, null, 2)}\n`);
|
|
console.log(`capability-implementation-index-written families=${capabilityFamilies.length} batches=27 pending=6609 output=${out}`);
|