import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const root = resolve(new URL('..', import.meta.url).pathname); const report = JSON.parse(await readFile(resolve(root, 'config/chrome-fem-verification.json'), 'utf8')); if (report.schemaVersion !== 1 || report.status !== 'pass' || report.browserId !== 'chrome' || !/Chrome/i.test(report.browser?.product || '') || report.crossOriginIsolated !== true) throw new Error('Chrome FEM verification is not passing.'); if (!report.geometry?.valid || report.solve?.status !== 'solved' || report.solve.strategy !== 'local-reference' || report.solve.nodes !== 2 || report.solve.nodeSets !== 1 || JSON.stringify(report.solve.resultFields) !== JSON.stringify(['displacement', 'stress']) || report.solve.maxDisplacement !== 0.00125 || report.solve.maxStress !== 25 || report.solve.csvBytes <= 0) throw new Error('FEM reference solve/set/result-field evidence is incomplete.'); if (report.persistence?.mode !== 'sqlite-opfs' || report.persistence.byteLength <= 0 || !/^[0-9a-f]{64}$/.test(report.persistence.hash) || report.persistence.roundTrip !== true || report.persistence.released !== true) throw new Error('FEM OPFS resource evidence is incomplete.'); if (report.opfs?.markerSuite !== 'FEM-ALL' || report.opfs.nodes !== 2 || report.opfs.markerRemoved !== true) throw new Error('FEM OPFS marker evidence is incomplete.'); if (report.afterRelease?.shapeCount !== 0 || report.afterRelease.kernelReferenceCount !== 0) throw new Error('FEM harness leaked ShapeHandles.'); console.log(JSON.stringify({ status: 'chrome-fem-pass', browser: report.browser.product, geometry: report.geometry, solve: report.solve, persistence: report.persistence, opfs: report.opfs, afterRelease: report.afterRelease }, null, 2))
