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/freecad-bitbybit-native-threeway.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.unknownDifferencesFail !== true || report.scenarioCount !== 26 || !Array.isArray(report.reports)) throw new Error('Three-way Boolean report schema is invalid.')
for (const entry of report.reports) {
  if (entry.bitbybit.differences.differences.length || entry.native.differences.differences.length) throw new Error(`Unknown three-way Boolean difference in ${entry.id}.`)
  if (!Number.isInteger(entry.native.historyRecordCount) || entry.native.historyRecordCount <= 0) throw new Error(`Missing native history records in ${entry.id}.`)
}
console.log(JSON.stringify({ status: 'freecad-threeway-pass', scenarioCount: report.scenarioCount, nativeOcctVersion: report.nativeOcctVersion }, null, 2))
