import assert from 'node:assert/strict'; import {readFileSync,writeFileSync,copyFileSync}from'node:fs'; import {createHash}from'node:crypto'; const read=p=>JSON.parse(readFileSync(p)); const art=p=>({path:p,sha256:createHash('sha256').update(readFileSync(p)).digest('hex')}); const directory=readFileSync('/tmp/turkos-k2100-single-cpu-control-review.txt','utf8').trim(); const source='scripts/os-acceptance/k2100-duration-window-check.mjs'; copyFileSync(source,directory+'/corrected-check.mjs.txt');copyFileSync('/tmp/turkos-k2100-single-cpu-control-review.mjs',directory+'/harness.mjs.txt'); const previous=read(directory+'/original-sequence.json');let changed=[]; for(const a of previous.pins)if(art(a.path).sha256!==a.sha256)changed.push(a.path); assert.deepEqual(changed,[source]); const extract=p=>{const s=readFileSync(p,'utf8');const m=s.match(/for \(const \[name, index, value\] of (\[\['root'[\s\S]*?\]\])\)\s+reject\('monitor '/);assert.ok(m);return new Function('cpus','return '+m[1]);}; const oldControls=extract(directory+'/original-check.mjs.txt'),newControls=extract(source); const short=read('reports/os-implementation/K2100-duration-review-QQ5548/report.json'),physical=read(short.physical.path);const row=physical.windowCheckpoints[0].workloadMonitor; const cases=[]; for(const cpus of [1,2,4]){ const model=row.slice();model[2]=cpus;model[46]=cpus;model[47]=cpus; for(const[name,index,value]of newControls(cpus)){ assert.notEqual(value,model[index],cpus+' CPU '+name+' must change bytes');cases.push({cpuCount:cpus,name,index,before:model[index],after:value,modeled:true}); } } const originalNoops=oldControls(1).filter(([name,index,value])=>[46,47].includes(index)&&value===1).map(([name])=>name); assert.deepEqual(originalNoops,['owner count','guard count']); const retryPath='reports/os-implementation/K2100-duration-window-proof-3uvEZe/report.json';const retry=read(retryPath);assert.equal(retry.status,'DURATION_WINDOW_PHYSICAL_COMPONENT_PASSED');assert.equal(retry.rejectedControlCount,58); const report={status:'SINGLE_CPU_HOST_CONTROLS_CORRECTED_AND_TESTED',guestAccepted:false,productAccepted:false, scope:'The original host checker wrote 1 over the already-1 owner/guard counts for one CPU. Corrected mutations use 2 for that profile; all mutations must now change actual captured bytes before refusal is checked. Forty-five explicit modeled CPU-count/control combinations change bytes, and the archived real four-CPU short run passes all 58 bad-record checks again. This creates no one-CPU guest evidence and does not alter the running kernel or capture harness.', original:art(directory+'/original-check.mjs.txt'),corrected:art(directory+'/corrected-check.mjs.txt'),harness:art(directory+'/harness.mjs.txt'),originalSequence:art(directory+'/original-sequence.json'),unchangedOtherPins:previous.pins.length-1,originalNoops,cases,shortRetry:art(retryPath),sameImage:previous.sameImage}; writeFileSync(directory+'/report.json',JSON.stringify(report,null,2)+'\n');console.log(JSON.stringify({status:report.status,report:directory+'/report.json',modeledControls:cases.length,shortBadRecordsRejected:58}));