import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const report = JSON.parse(await readFile(resolve(new URL('..', import.meta.url).pathname, 'config/chrome-native-loft-history-verification.json'), 'utf8'))
if (report.status !== 'pass' || report.browserId !== 'chrome' || report.crossOriginIsolated !== true || report.nativeCapabilities?.operations?.includes('loft') !== true || report.history?.recordCount <= 0 || report.history?.relations?.generated <= 0 || !report.history?.sourceObjects?.includes('FirstSection') || !report.history?.sourceObjects?.includes('SecondSection') || report.result?.bitbybitSolids !== 1 || Math.abs(report.result.bitbybitVolume - 20) > 1e-7 || report.opfs?.markerPayload?.sections !== 2 || report.opfs?.markerRemoved !== true || report.afterRelease?.shapeCount !== 0 || report.afterRelease?.kernelReferenceCount !== 0) throw new Error('Chrome native Loft history evidence is invalid.')
console.log(JSON.stringify({ status: 'chrome-native-loft-history-pass', records: report.history.recordCount, relations: report.history.relations, afterRelease: report.afterRelease }, null, 2))
