import fs from 'node:fs';
import crypto from 'node:crypto';
const r=JSON.parse(fs.readFileSync('public/reports.json','utf8'));
for(const[p,sha]of Object.entries(r.sourceHashes))if(crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex')!==sha)throw new Error('Stale report, changed: '+p);
if(r.runs.fixed.exitCode!==0||r.runs.fixed.failed!==0||r.runs.fixed.passed!==r.runs.fixed.total)throw new Error('Fixed capture is not green');
if(r.runs.broken.exitCode!==1||r.runs.broken.failed<9)throw new Error('Expected intentional failures in all nine scenarios');
for(let i=1;i<=9;i++){
 const prefix=String(i).padStart(2,'0')+' ·';
 if(!r.runs.broken.assertions.some(a=>a.ancestorTitles.some(t=>t.startsWith(prefix))&&a.status==='failed'))throw new Error('Missing failure scenario '+i);
}
console.log('Verified source hashes, fixed exit 0, broken exit 1 and failures in all 9 scenarios. Browser Mode status: '+r.browser.status);
