import {readFileSync} from "node:fs"; import {fileURLToPath} from "node:url"; import {join,dirname} from "node:path"; const base=dirname(fileURLToPath(import.meta.url)); const {observations:rows}=JSON.parse(readFileSync(join(base,"observations.json"),"utf8")); const fields=["application_date_trigger","part1_named","original_comments_carried","part1_no_fresh_comments","other_procedures_comment_opportunity"]; if(rows.length!==6 || new Set(rows.map(r=>r.source_id)).size!==6)throw Error("Sample must contain six unique fixed pages."); for(const r of rows){if(r.submission_tested!==false || r.actual_deadline!==null || r.actual_appeal_reference!==null)throw Error("Unexpected case-level assertion");for(const f of fields)if(!["YES","NOT_STATED","UNOBSERVABLE"].includes(r[f]))throw Error("Invalid code");} const counts=Object.fromEntries(fields.map(f=>[f,{YES:rows.filter(r=>r[f]==="YES").length,NOT_STATED:rows.filter(r=>r[f]==="NOT_STATED").length,UNOBSERVABLE:rows.filter(r=>r[f]==="UNOBSERVABLE").length}])); console.log(JSON.stringify({sample:rows.length,counts},null,2)); const expected=[1,1,2,1,0]; fields.forEach((f,i)=>{if(counts[f].YES!==expected[i])throw Error("Reported count changed: "+f)});