3 lines
4.8 KiB
JavaScript
3 lines
4.8 KiB
JavaScript
import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { createRequire } from "node:module"; import { pathToFileURL } from "node:url";
|
|
const root="/home/mes123456/FreeCADWasmDev/working/FreeCAD", build=path.resolve(process.argv[2]||path.join(root,"freecad-source/build-web/configure/bin")); globalThis.__dirname=`${build}${path.sep}`; globalThis.require=createRequire(import.meta.url); const loader=await import(pathToFileURL(path.join(build,"FreeCADWebPointsRuntimeProbe.js"))); const kernel=await loader.default({wasmBinary:fs.readFileSync(path.join(build,"FreeCADWebPointsRuntimeProbe.wasm")),print:()=>{},printErr:()=>{}}); const mp=path.join(root,"docs/p6/python-api-manifest.json"), manifest=JSON.parse(fs.readFileSync(mp,"utf8")); const records=manifest.records.filter(r=>r.module==="Points"&&r.tier==="tier-1-readonly").map(r=>({apiId:r.id,name:r.name,family:r.family,sourcePath:r.evidence?.path,disposition:r.disposition})); if(records.length!==2)throw Error(`expected 2 Points records, got ${records.length}`); const req={cmd:"points.pythonFamilyBatch",args:{tier:"tier-1-readonly",records}}, invoke=v=>JSON.parse(String(kernel.ccall("fc_web_dispatch_json","string",["string"],[JSON.stringify(v)]))), success=invoke(req), repeated=invoke(req), cross=invoke({cmd:req.cmd,args:{tier:req.args.tier,records:[{...records[0],apiId:"py:BIM:class:Binding"} ]}}), malformed=invoke({cmd:req.cmd,args:{tier:"tier-2-pure",records}}); if(success.ok!==true||success.module!=="Points"||success.count!==2||success.records?.length!==2||success.resourcesReleased!==true)throw Error("Points family dispatch incomplete"); const terminal=new Set(["exposed","restricted","nonportable","not_implemented"]); if(success.records.some(r=>!terminal.has(r.status)||r.native!==true||r.resourcesReleased!==true||!r.sourceEntry||!r.sourceRevision))throw Error("Points family result non-terminal"); const counts=Object.fromEntries([...terminal].map(s=>[s,success.records.filter(r=>r.status===s).length])); if(counts.exposed!==1||counts.restricted!==1)throw Error(`unexpected Points disposition counts ${JSON.stringify(counts)}`); if(JSON.stringify(success)!==JSON.stringify(repeated)||cross.records?.[0]?.code!=="unmatched_source_record"||malformed.ok!==false)throw Error("Points replay/error boundary failed"); const hash=v=>crypto.createHash("sha256").update(JSON.stringify(v)).digest("hex"), fileHash=f=>crypto.createHash("sha256").update(fs.readFileSync(f)).digest("hex"), by=new Map(success.records.map(r=>[r.apiId,r])); for(const row of manifest.records){if(row.module!=="Points"||row.tier!=="tier-1-readonly")continue;const n=by.get(row.id);row.disposition=n.status;row.dispositionEvidence=["docs/p6/points-tier1-readonly-family-runtime.json"];row.dispositionReason=n.status==="restricted"?n.message:"native Points Python symbol resolution passed in the FreeCAD Web runtime";} fs.writeFileSync(mp,JSON.stringify(manifest,null,2)+"\n"); const report={schema:"freecad-web-p6-points-tier1-readonly-family-runtime/v1",taskId:"FW-P6-FPA-F1-POINTS",module:"Points",tier:"tier-1-readonly",status:"pass_with_restricted",sourceRevision:success.records[0]?.sourceRevision,route:{worker:"web/src/points.worker.ts",facade:"web/src/points-python-family-facade.ts",command:req.cmd,native:"freecad-source/src/WebAssembly/FreeCADCoreProbe/PointsRuntimeProbe.cpp:fc_web_dispatch_json"},input:req,inputSha256:hash(req),result:success,resultSha256:hash(success),replay:{equal:true,resultSha256:hash(repeated)},crossModuleBoundary:{result:cross,resultSha256:hash(cross)},malformedRequest:{result:malformed,resultSha256:hash(malformed)},dispositionCounts:counts,records:success.records.map(r=>({apiId:r.apiId,name:r.name,family:r.family,status:r.status,code:r.code,parameterSchema:r.parameterSchema,returnSchema:r.returnSchema,replay:r.replay,sourceEntry:r.sourceEntry,sourceRevision:r.sourceRevision,evidenceSha256:hash(r)})),resources:{resourcesReleased:true,documentMutation:false},artifacts:{wasm:{path:"web/public/kernel/FreeCADWebPointsRuntimeProbe.wasm",sha256:fileHash(path.join(root,"web/public/kernel/FreeCADWebPointsRuntimeProbe.wasm"))},loader:{path:"web/public/kernel/FreeCADWebPointsRuntimeProbe.js",sha256:fileHash(path.join(root,"web/public/kernel/FreeCADWebPointsRuntimeProbe.js"))}},boundaries:["PointsWorkbench remains restricted without FreeCADGui.","All selected statuses and hashes derive from compiled FreeCAD source through fc_web_dispatch_json."]}; fs.writeFileSync(path.join(root,"docs/p6/points-tier1-readonly-family-runtime.json"),JSON.stringify(report,null,2)+"\n"); fs.writeFileSync(path.join(root,"docs/freecad-p6-points-tier1-readonly-family.log"),JSON.stringify({status:report.status,count:2,dispositionCounts:counts,resultSha256:report.resultSha256})+"\n"); console.log(JSON.stringify({status:report.status,count:2,dispositionCounts:counts,resultSha256:report.resultSha256}));
|