const fs=require('fs');
const path=require('path');
const root=path.resolve(__dirname,'..');
function assert(cond,msg){if(!cond)throw new Error(msg);}
const html=fs.readFileSync(path.join(root,'workbench','index.html'),'utf8');
const js=fs.readFileSync(path.join(root,'workbench','app.js'),'utf8');
const css=fs.readFileSync(path.join(root,'workbench','styles.css'),'utf8');
assert(html.includes('Clinical Reasoning Database'),'Missing workbench title');
assert(html.includes('Claims')&&html.includes('Evidence')&&html.includes('Validation'),'Missing primary tabs');
for(const token of ['sourceType','locator','section','subsection','recommendation','paragraphOrBullet','claimSupported','supportSummary']) assert(js.includes(token),`Missing ${token}`);
for(const token of ['Generic','Brands','OCR aliases','Common misspellings','Renal dosing','CRRT','Y-site compatibility','Crushability','Therapeutic substitutions','Version history']) assert(js.includes(token),`Missing field ${token}`);
assert(js.includes('Primary and secondary reviewers must be different'),'Independent review not enforced');
assert(js.includes('Source section is required'),'Section validation not enforced');
assert(js.includes('At least one precise source locator is required'),'Precise locator not enforced');
assert(js.includes('Conflicting evidence requires documented resolution'),'Conflict gate missing');
assert(css.length>3000,'Stylesheet unexpectedly small');
for(const file of ['structural_medication.json','structural_claim.json','structural_evidence.json']) JSON.parse(fs.readFileSync(path.join(root,'data','examples',file),'utf8'));
console.log('Sprint 4 workbench static tests passed.');
