// A controlled rule-only diagnostic. Reuse saved model answers without making new predictions. import fs from 'node:fs' import path from 'node:path' import {ContractEngine} from '../server/contract-engine.mjs' const out=path.resolve('../output/kimi-jev-evaluation-20261013') const results=[] for(const [id,source] of [['G19','runs-v1.2-dense'],['H02','runs-dense'],['H09','runs-dense']]){ const run=JSON.parse(fs.readFileSync(path.join(out,source,id+'.json'),'utf8')) const plan=structuredClone(JSON.parse(fs.readFileSync(path.join(out,run.planFile),'utf8')).plan) const changes=[] for(const rule of plan.rules){ const terms=[...rule.condition.terms,...(rule.then?.terms||[])] if(['occurrence','sequence'].includes(rule.mode)&&terms.every(t=>plan.observers.find(o=>o.id===t.observer)?.input==='pair')){ changes.push({rule:rule.id,before:rule.confirmation_frames,after:1}) rule.confirmation_frames=1 } } const engine=new ContractEngine(plan,{cameraId:run.clipId,sourceId:run.sourceId}) const base=Date.parse(run.baseTime)/1000 const signals=Object.fromEntries(run.simulatedSignals.map(k=>[k,{value:true,observedAt:base-1,validUntil:base+86400,source:'explicit_test_injection'}])) for(const o of run.observations)engine.observe({...o.trace,cameraId:run.clipId,sourceId:run.sourceId,quality:run.groundingPassed?'usable':'unregistered_target'},Object.fromEntries(o.predictions.map(p=>[p.observer,p.answer||{choice:null,abstained:true}])),{signals}) results.push({caseId:id,sourceRun:source+'/'+id+'.json',method:'Rule-only replay of the same saved two-image visual answers. A transition is counted once; the model is not rerun.',changes,beforeNotices:run.runtime.notices.length,afterNotices:engine.notices.length,notices:engine.notices,plan}) } fs.writeFileSync(path.join(out,'transition-confirmation-diagnostic.json'),JSON.stringify(results,null,2)) console.log(results.map(r=>({caseId:r.caseId,before:r.beforeNotices,after:r.afterNotices})))