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-native-pad-history-verification.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.browserId !== 'chrome' || report.executionContext !== 'dedicated-worker' || report.crossOriginIsolated !== true || report.status !== 'pass' || report.workerDisposed !== true) throw new Error('Chrome native Pad history Worker evidence is invalid.')
if (report.nativeCapabilities?.availability !== 'available' || report.nativeCapabilities?.operations?.includes('pad') !== true || report.execution?.status !== 'completed' || report.execution.recordCount <= 0 || report.execution.crossKindRecords <= 0 || JSON.stringify(report.execution.profileKinds.sort()) !== JSON.stringify(['edge', 'face', 'vertex']) || report.execution.summary?.isValid !== true || report.execution.summary?.solids !== 1 || Math.abs(report.execution.summary.volume - 30) > 1e-7) throw new Error('Chrome native Pad Generated/Modified/Deleted evidence is incomplete.')
console.log(JSON.stringify({ status: 'chrome-native-pad-history-pass', browserId: report.browserId, nativeCapabilities: report.nativeCapabilities, execution: report.execution }, null, 2))
