29 lines
4.5 KiB
JavaScript
29 lines
4.5 KiB
JavaScript
#!/usr/bin/env node
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { createRequire } from "node:module";
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
|
|
const build = path.join(root, "freecad-source/build-web/configure/bin");
|
|
globalThis.__dirname = `${build}${path.sep}`;
|
|
globalThis.require = createRequire(import.meta.url);
|
|
const batch = JSON.parse(fs.readFileSync(path.join(root, "docs/current/module-batch-manifest.json"), "utf8"));
|
|
if (batch.batchId !== "d14eb33f60fd42492c60105a" || batch.selected?.module !== "Inspection" || batch.selected?.tier !== "object-contract" || batch.selected?.family !== "geometry-recompute") throw new Error("unexpected Inspection geometry-recompute batch");
|
|
const factory = (await import(`file://${path.join(build, "FreeCADWebInspectionRuntimeProbe.js")}`)).default;
|
|
const kernel = await factory({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebInspectionRuntimeProbe.wasm")) });
|
|
const records = batch.records.map(([apiId, name, disposition, source]) => ({ apiId, name, family: "geometry-recompute", sourcePath: source, disposition }));
|
|
const request = { cmd: "inspection.pythonFamilyBatch", args: { tier: "object-contract", records } };
|
|
const raw = String(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify(request)]));
|
|
const native = JSON.parse(raw);
|
|
const replay = JSON.parse(String(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify(request)])));
|
|
const crossModule = JSON.parse(String(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify({ ...request, args: { ...request.args, records: [{ ...records[0], apiId: "obj:Other:Inspection::Group" }] } })])));
|
|
const row = native.records?.[0];
|
|
if (native.ok !== true || native.tier !== "object-contract" || native.resourcesReleased !== true || native.count !== 1 || row?.status !== "exposed" || row?.code !== "native_object_contract" || row?.resourcesReleased !== true) throw new Error("Inspection::Feature native object contract failed");
|
|
if (JSON.stringify(replay) !== JSON.stringify(native)) throw new Error("Inspection::Group replay changed native output");
|
|
if (crossModule.records?.[0]?.code !== "unmatched_source_record") throw new Error("Inspection object adapter accepted a cross-module record");
|
|
const result = { count: records.length, resourcesReleased: true, resourceLifecycle: "document-created-linked-recomputed-closed", dispositionCounts: { exposed: 1, restricted: 0, nonportable: 0, not_implemented: 0 }, native };
|
|
const report = { schema: "freecad-web-inspection-document-graph-module-batch-runtime/v1", taskId: "FW-P6-FPA-Y", batchId: batch.batchId, module: "Inspection", tier: "object-contract", family: "document-graph", status: "pass", dispatcher: "fc_web_dispatch_json", route: { command: "inspection.pythonFamilyBatch", native: "freecad-source/src/WebAssembly/FreeCADCoreProbe/InspectionRuntimeProbe.cpp:fc_web_dispatch_json", facade: "web/src/inspection-python-family-facade.ts", worker: "web/src/inspection.worker.ts", loader: "web/src/module-loader.ts", routerApi: ["WebModuleRouter.setArtifact", "WebModuleRouter.loadManifest", "WebModuleRouter.preload"] }, input: { cmd: request.cmd, args: request.args }, result, resultSha256: crypto.createHash("sha256").update(JSON.stringify(result)).digest("hex"), replay: { equal: true }, crossModule: crossModule.records[0], records: [{ ...row, sourceEntry: records[0].sourcePath }], artifacts: { module: "Inspection", worker: "inspection.worker.ts", revision: row.sourceRevision, runtimeUrl: "/kernel/FreeCADWebInspectionRuntimeProbe.js", wasmUrl: "/kernel/FreeCADWebInspectionRuntimeProbe.wasm", dataUrl: null, assetBaseUrl: "/kernel/", runtimeSha256: crypto.createHash("sha256").update(fs.readFileSync(path.join(build, "FreeCADWebInspectionRuntimeProbe.js"))).digest("hex"), wasmSha256: crypto.createHash("sha256").update(fs.readFileSync(path.join(build, "FreeCADWebInspectionRuntimeProbe.wasm"))).digest("hex"), buildProfile: "fast-dev" }, boundaries: ["The fixture covers native Inspection::Group creation, one Part::Box member link, recompute and document release.", "All statuses and lifecycle evidence come from compiled FreeCAD through fc_web_dispatch_json; JavaScript only validates the focused batch."] };
|
|
fs.writeFileSync(path.join(root, "docs/p6/inspection-document-graph-module-batch-1714f3192867088b172b8252-runtime.json"), JSON.stringify(report, null, 2) + "\n");
|
|
console.log(JSON.stringify({ result: report.status, batchId: report.batchId, code: row.code, resourceLifecycle: result.resourceLifecycle }));
|
|
process.exit(0);
|