import assert from 'node:assert/strict'; import {readFileSync,writeFileSync,mkdtempSync,copyFileSync} from 'node:fs'; import {createHash} from 'node:crypto'; import {join,resolve,relative} from 'node:path'; import {fileURLToPath} from 'node:url'; import {FEATURE_PROFILES} from './k2150-native-guest-runner.mjs'; import {faultConfiguration} from './k2150-native-storage-fixture.mjs'; import {checkStorageComponent} from './features/k2150-native-check.mjs'; const [matrixPath,candidatePath]=process.argv.slice(2);assert.ok(matrixPath&&candidatePath&&process.argv.length===4); const read=p=>JSON.parse(readFileSync(p)),artifact=path=>({path,sha256:createHash('sha256').update(readFileSync(path)).digest('hex')}); const checked=a=>{assert.equal(artifact(a.path).sha256,a.sha256,a.path);return readFileSync(a.path);}; const directory=mkdtempSync('reports/os-implementation/K2150-native-storage-proof-'); copyFileSync(fileURLToPath(import.meta.url),join(directory,'harness.mjs.txt')); try{ const candidate=read(candidatePath),life=read(join(matrixPath,'scoped-lifecycle.json')),preflight=read(join(matrixPath,'preflight.json')); assert.equal(candidate.status,'COMPILED_FEATURE_CANDIDATE');assert.equal(candidate.slug,'shutdown-native-flush'); assert.equal(life.status,'RUNNER_PASSED');assert.equal(life.selection,'all');assert.equal(life.frozenStable,true); assert.deepEqual(life.candidate,artifact(candidatePath));assert.equal(life.profiles.length,54); assert.ok(candidate.imageSpan.bytes>0&&candidate.imageSpan.bytes<=8388608); for(const a of Object.values(candidate.artifacts))checked(a); for(const a of Object.values(candidate.sources))checked(a); checked(candidate.spec);checked(candidate.harness);checked(preflight.harness); const expected=new Set(FEATURE_PROFILES.flatMap(p=>[0,1,2].map(c=>p.id+':'+c))),seen=new Set(),profiles=[]; for(const row of life.profiles){ assert.equal(row.status,'GUEST_RETURNED');assert.equal(row.allOwnedGuestsStopped,true); const p=row.profile,id=p.baseProfile+':'+p.caseId;assert.ok(expected.has(id)&&!seen.has(id));seen.add(id); const expectedProfile=FEATURE_PROFILES.find(x=>x.id===p.baseProfile);assert.ok(expectedProfile); for(const key of ['route','memoryMiB','cpuCount'])assert.equal(p[key],expectedProfile[key]); const persisted=read(join(matrixPath,p.id,'result.json'));assert.deepEqual(persisted,row); assert.equal(row.storage.caseId,p.caseId); assert.equal(checked(row.storage.fault).toString(),faultConfiguration(p.caseId)); assert.deepEqual(row.storage.before,preflight.fixtures.block); checked(row.dtb); const stages=row.experimentStages.map(s=>{ assert.equal(s.captures.length,1);assert.equal(s.captures[0].symbol,'OS_K2150_EVIDENCE'); const bytes=checked(s.captures[0]); const dmaPages=s.dmaPages.map((page,index)=>{ assert.equal(page.index,index);assert.ok(page.address>=0x40000000&&page.address+4096<=0x40000000+p.memoryMiB*1024*1024); return {...page,bytes:checked(page)}; });return {stage:s.stage,bytes,dmaPages}; }); assert.equal(row.final.length,1); const result=checkStorageComponent({caseId:p.caseId,stages,final:checked(row.final[0]),serial:checked(row.serial).toString(), before:checked(row.storage.before),after:checked(row.storage.after)}); profiles.push({profile:p,result,source:artifact(join(matrixPath,p.id,'result.json'))}); } assert.deepEqual(seen,expected); const report={status:'NATIVE_STORAGE_PHYSICAL_COMPONENT_PASSED',guestAccepted:false,productAccepted:false, scope:'All eighteen hardware/boot profiles, each with completed, metadata EIO and journal timeout cases. Actual DMA descriptors, available/used entries, request buffers and final disposable disks were checked. This component does not establish the complete EL0 shutdown flow or K2150 milestone admission.', candidate:artifact(candidatePath),lifecycle:artifact(join(matrixPath,'scoped-lifecycle.json')),preflight:artifact(join(matrixPath,'preflight.json')), checker:artifact('scripts/os-acceptance/features/k2150-native-check.mjs'),profiles}; const reportPath=join(directory,'report.json');writeFileSync(reportPath,JSON.stringify(report,null,2)+'\n'); console.log(JSON.stringify({status:report.status,report:reportPath,profiles:18,storageCases:54})); }catch(error){ const path=join(directory,'report.json');writeFileSync(path,JSON.stringify({status:'NATIVE_STORAGE_PHYSICAL_COMPONENT_FAILED',guestAccepted:false,productAccepted:false,error:error.stack},null,2)+'\n'); console.error(path);throw error; }