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-sketcher-stress-verification.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.browserId !== 'chrome' || report.status !== 'pass' || report.crossOriginIsolated !== true) throw new Error('Chrome Sketcher stress verification is not passing.')
const stress = report.stress ?? {}
if (stress.seed !== 539363331 || stress.models !== 500 || stress.solves !== 1000 || stress.deterministicMismatches !== 0 || stress.unexpectedResults !== 0 || stress.maxIterations > 64 || stress.maxResidual > 1e-12 || stress.digest !== 'edac8aed' || stress.durationMs > 2_000) throw new Error('Chrome Sketcher stress deterministic or performance evidence is incomplete.')
if (report.opfs?.markerSuite !== 'SK-12' || report.opfs.markerModels !== 500 || report.opfs.markerSolves !== 1000 || report.opfs.markerRemoved !== true) throw new Error('Chrome Sketcher stress OPFS marker was not verified and removed.')
console.log(JSON.stringify({ status: 'chrome-sketcher-stress-pass', browser: report.browserId, stress: report.stress, opfs: report.opfs }, null, 2))
