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-pipe-history-verification.json'), 'utf8'))
if (report.status !== 'pass' || report.browserId !== 'chrome' || report.crossOriginIsolated !== true || report.nativeCapabilities?.operations?.includes('pipe') !== true || report.history?.recordCount <= 0 || report.history?.relations?.modified <= 0 || report.history?.relations?.generated <= 0 || !report.history?.sourceObjects?.includes('Profile') || !report.history?.sourceObjects?.includes('Spine') || report.result?.bitbybitSolids !== 1 || Math.abs(report.result.bitbybitVolume - 20) > 1e-7 || report.opfs?.markerPayload?.spineEdges !== 1 || report.opfs?.markerRemoved !== true || report.afterRelease?.shapeCount !== 0 || report.afterRelease?.kernelReferenceCount !== 0) throw new Error('Chrome native Pipe history evidence is invalid.')
console.log(JSON.stringify({ status: 'chrome-native-pipe-history-pass', records: report.history.recordCount, relations: report.history.relations, afterRelease: report.afterRelease }, null, 2))
