const {chromium}=require('C:/Users/PC/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright'); const fs=require('fs'),path=require('path'),assert=require('assert/strict'),{pathToFileURL}=require('url'),crypto=require('crypto'); const file=path.resolve(__dirname,'../demo.html'),url=pathToFileURL(file).href,screen=path.join(__dirname,'screenshots'); fs.mkdirSync(screen,{recursive:true}); (async()=>{ const browser=await chromium.launch({headless:true,executablePath:'C:/Program Files/Google/Chrome/Application/chrome.exe'}); const results=[],errors=[],external=[]; const record=(name,expected,actual)=>{assert.deepEqual(actual,expected,name);results.push({check:name,expected,actual});}; const contains=async(p,selector,text,name)=>record(name||text,true,(await p.locator(selector).textContent()).includes(text)); const click=async(p,id)=>p.locator('#'+id).click(); const tab=async(p,id)=>click(p,'tab-'+id); const width=async(p,label)=>record(label,false,await p.evaluate(()=>document.documentElement.scrollWidth>innerWidth+1)); const watch=p=>{p.on('pageerror',e=>errors.push(String(e)));p.on('request',r=>{if(!r.url().startsWith('file:'))external.push(r.url());});}; const guide=async(p,id,steps)=>{await click(p,'guide-'+id);for(let i=0;i{let s=Methodology.initial();for(const step of Methodology.GUIDES.happy.steps)s=Methodology.transition(s,step[2]);const saved=JSON.stringify(s.versions[0].snapshot);const next=Methodology.transition(s,{type:'context'});return{same:JSON.stringify(next.versions[0].snapshot)===saved,oldContext:s.context.id,newContext:next.context.id,edges:next.versions[0].snapshot.edges.map(e=>e.type),causality:next.versions[0].snapshot.decision.effect};}); record('Чистая логика: исходное состояние не мутирует','context@1',pure.oldContext);record('Чистая логика: новый контекст отдельный','context@2',pure.newContext);record('Чистая логика: копия версии неизменна',true,pure.same);record('Версия включает четыре типа связей',['formula','influence','membership','constraint'],pure.edges);record('Версия не выдумывает причинное доказательство','Причинный эффект не установлен',pure.causality); record('Ошибки JavaScript',[],errors);record('Внешние запросы',[],external); const result={status:'PASS',checked_at:new Date().toISOString(),browser:await browser.version(),sha256:crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'),checks:results.length,results,page_errors:errors,external_requests:external};fs.writeFileSync(path.join(__dirname,'observations.json'),JSON.stringify(result,null,2));console.log(JSON.stringify({status:result.status,checks:result.checks,sha256:result.sha256})); }finally{await browser.close();} })().catch(e=>{console.error(e);process.exitCode=1;});