// Independent replay of raw K2160 guest captures. This module never launches // QEMU and a successful subproof alone never updates the roadmap. import assert from 'node:assert/strict'; import {createHash} from 'node:crypto'; import {readFileSync,realpathSync} from 'node:fs'; import {resolve,sep} from 'node:path'; import {spawnSync} from 'node:child_process'; import {ledger} from './k2155-dma-authority-check.mjs'; import {reopenStages,readOnlyImageSpans,collectReopenPhysical} from './k2160-capture.mjs'; const SECTOR=512,BASE=0x40000000n,USER=0x80000000n,GEN=0x21600001n,REFUSED=1n<<63n; const W=b=>{assert.ok(Buffer.isBuffer(b)&&b.length%8===0);return Array.from({length:b.length/8},(_,i)=>b.readBigUInt64LE(i*8));}; const u=(b,at)=>b.readBigUInt64LE(at); const sha=b=>createHash('sha256').update(b).digest('hex'); const zero=b=>assert.ok(b.every(v=>v===0),'expected zeroed bytes'); const toBig=(v,label)=>{ if(typeof v==='bigint')return v; assert.match(v,/^(?:0x[0-9a-f]{1,16}|[0-9a-f]{1,16})$/i,label); return BigInt(v.startsWith('0x')?v:'0x'+v); }; const label=(phase,caseId)=>`phase ${phase}, case ${caseId}`; function exactRows(s,name,count){const rows=W(s[name]);assert.equal(rows.length,count,name);return rows;} function sector(disk,lba){assert.ok(Buffer.isBuffer(disk)&&disk.length===1024*1024);return disk.subarray(lba*SECTOR,(lba+1)*SECTOR);} function expectedSource(seed){ const b=Buffer.alloc(2048,0xe7),mask=(1n<<64n)-1n; for(let i=0;i<1537;i++){const n=BigInt(i),shift=BigInt(i%64),r=((seed<>(64n-shift)))&mask;b[i]=Number(((n*37n)^(n>>5n)^r)&255n);} return b; } function expectedMetadata(){const b=Buffer.alloc(512);for(const[i,size,lba]of [[0,513,30],[1,512,32],[2,1537,128]]){ b.writeUInt32LE(i+1,i*32);b.writeBigUInt64LE(BigInt(size),i*32+8);b.writeBigUInt64LE(BigInt(lba),i*32+16); }return b;} function expectedJournal(seed,boot,digest){const b=Buffer.alloc(512);b.write('K2160FS1');b.writeBigUInt64LE(seed,8);b.writeBigUInt64LE(boot,16);digest.copy(b,24);return b;} function requestSequence(phase,caseId){ if(phase===1)return [[1,128],[1,129],[1,130],[1,131],[4,0],[1,18],[4,0],[1,120],[4,0]]; if(caseId===3)return [];if(caseId===2)return [[0,16]]; return [[0,16],[0,17],[0,18],[0,128],[0,129],[0,130],[0,131]]; } function comparedPages(first,current,layout,owned){ const a=ledger(first,layout),b=ledger(current,layout); assert.equal(a.pages-b.pages,BigInt(owned.length)); assert.equal(b.live.size-a.live.size,owned.length); for(const [address,generation] of a.live)assert.equal(b.live.get(address),generation,'prior live owner changed'); for(const address of owned){assert.ok(!a.live.has(address)&&b.live.has(address));assert.ok(a.free.some(([lo,hi])=>address>=lo&&address=BASE&&p+4096n<=memoryEnd&&p%4096n===0n); comparedPages(baseline,s.authority,layout,pages); const copy=Buffer.from(kernel);assert.equal(u(copy,16),0n);copy.writeBigUInt64LE(u(l1,16),16);assert.deepEqual(l1,copy); zero(l2.subarray(8));assert.deepEqual(W(l3.subarray(0,32)),[row[1]|0x0020000000000fc3n,row[2]|0x0060000000000f43n,0n,row[3]|0x0060000000000f43n]);zero(l3.subarray(32)); assert.deepEqual(s['live-user-code'].subarray(0,program.length),program);zero(s['live-user-code'].subarray(program.length)); zero(s['live-user-data']);zero(s['live-user-stack']); const cpu=exactRows(s,'OS_K2160_CPU_STATE',8);assert.equal(cpu[0],row[0]);assert.equal(cpu[1],BigInt(symbols.__os_fx_vectors.address)); const calls=exactRows(s,'OS_K2160_EL0_REQUESTS',192),call=[0,4,10][index],r=calls.slice(call*16,call*16+16); assert.equal(s['live-el0-frame'].length,824);assert.deepEqual(s['live-el0-frame'],s.OS_K2160_EL0_FRAMES.subarray(index*832,index*832+824)); zero(s.OS_K2160_EL0_FRAMES.subarray(index*832+824,(index+1)*832)); assert.deepEqual(W(s['live-el0-frame'].subarray(0,24)),r.slice(3,6));assert.equal(u(s['live-el0-frame'],64),16n); for(const[at,field]of [[248,9],[256,8],[264,10],[272,11],[816,12]])assert.equal(u(s['live-el0-frame'],at),r[field]); assert.ok(cpu[3]=USER+4n&&r[8]<=USER+BigInt(program.length)&&r[8]%4n===0n); assert.equal(program.readUInt32LE(Number(r[8]-USER-4n)),0xd4000001,'SVC at recorded ELR'); assert.ok(r[9]>=USER+12304n&&r[9]<=USER+16384n&&r[9]%16n===0n); assert.equal(r[10]&0x3c0n,0x3c0n);assert.equal(r[11],0x56000000n);assert.equal(r[12],8n);assert.equal(r[13],BigInt(i+1)); assert.equal(r[14],i===10?1n:0n);assert.ok(r[15]>=stackLow&&r[15]+832n<=stackTop&&r[15]%16n===0n); } zero(last.OS_K2160_EL0_REQUESTS.subarray(11*128)); const stageCalls=stage=>stage===0?0:stage===330?1:stage===300?4:stage===331?5:stage===301?8:11; for(const s of snapshots){const stage=Number(u(s.OS_K2160_EVIDENCE,8)),n=stageCalls(stage); assert.deepEqual(s.OS_K2160_EL0_REQUESTS.subarray(0,n*128),last.OS_K2160_EL0_REQUESTS.subarray(0,n*128));zero(s.OS_K2160_EL0_REQUESTS.subarray(n*128)); const framesSeen=stage===0?0:[330,300].includes(stage)?1:[331,301].includes(stage)?2:3; assert.deepEqual(s.OS_K2160_EL0_FRAMES.subarray(0,framesSeen*832),frames.subarray(0,framesSeen*832));zero(s.OS_K2160_EL0_FRAMES.subarray(framesSeen*832)); } return {syscalls:11,liveSvcFrames:3}; } function descriptor(b,at,address,length,flags,next){assert.equal(u(b,at),address);assert.equal(b.readUInt32LE(at+8),length); assert.equal(b.readUInt16LE(at+12),flags);assert.equal(b.readUInt16LE(at+14),next);} export function checkReopenDmaRequest(s,seq,op,lba,disk,source,metadata,journal,frames,hz){ const e=exactRows(s,'OS_K2160_EVIDENCE',512),r=e.slice(64+(seq-1)*16,64+seq*16); assert.deepEqual(r.slice(0,9),[BigInt(seq),BigInt(op),BigInt(lba),BigInt(seq),0n,BigInt(op===0?513:1),0n,BigInt(op),BigInt(lba)]); assert.ok(r[9]>0n&&r[10]>r[9]&&r[10]-r[9]<=2n*hz&&r[11]>=r[9]&&r[11]s['dma-'+i]);for(const b of [desc,avail,used,buffer])assert.equal(b.length,4096); descriptor(desc,0,frames[3],16,1,1); if(op===4){descriptor(desc,16,frames[3]+16n,1,2,0);} else{descriptor(desc,16,frames[3]+512n,512,op===0?3:1,2);descriptor(desc,32,frames[3]+16n,1,2,0);} assert.equal(avail.readUInt16LE(2),seq);assert.equal(avail.readUInt16LE(4+((seq-1)%8)*2),0); assert.equal(used.readUInt16LE(2),seq);assert.equal(used.readUInt32LE(4+((seq-1)%8)*8),0); assert.equal(used.readUInt32LE(8+((seq-1)%8)*8),op===0?513:1); assert.equal(buffer.readUInt32LE(0),op);assert.equal(buffer.readUInt32LE(4),0);assert.equal(u(buffer,8),BigInt(lba));assert.equal(buffer[16],0); if(op===1){const expected=lba===18?metadata:lba===120?journal:source.subarray((lba-128)*512,(lba-127)*512); assert.deepEqual(buffer.subarray(512,1024),expected);} if(op===0)assert.deepEqual(buffer.subarray(512,1024),sector(disk,lba)); return r; } export function checkReopenPhysicalSnapshots({snapshots,phase,caseId,bootId,previousBoot,seed,memoryMiB,symbols,elf,imageSpan,imageSha256,programs,diskBefore,diskAfter}){ assert.ok([256,512,1024].includes(memoryMiB));assert.ok([1,2].includes(phase)); const boot=toBig(bootId,'bootId'),old=toBig(previousBoot,'previousBoot'),key=toBig(seed,'seed');assert.ok(boot>0n&&old>0n&&key>0n); assert.deepEqual(snapshots.map(s=>Number(u(s.OS_K2160_EVIDENCE,8))),reopenStages(phase,caseId)); const last=snapshots.at(-1),first=snapshots[0],layout=exactRows(first,'OS_K1000_AUTHORITY_LAYOUT_EXPECTED',24).map(Number); const imageSpans=readOnlyImageSpans(elf,imageSpan); for(const span of imageSpans)assert.deepEqual(first[span.name],elf.subarray(span.fileOffset,span.fileOffset+span.size),'loaded readonly Image segment'); const imageClaim=Buffer.from(imageSha256,'hex');assert.equal(imageClaim.length,32); const source=expectedSource(key),metadata=expectedMetadata(),digest=Buffer.from(sha(source.subarray(0,1537)),'hex'),journal=expectedJournal(key,boot,digest); const memoryEnd=BASE+BigInt(memoryMiB)*1048576n,baseline=first.authority,kernelRoot=exactRows(first,'OS_K2160_CPU_STATE',8)[0]; const stackLow=BigInt(symbols.OS_K900_STACK.address)+4096n,stackTop=stackLow+65536n-16n; assert.ok(kernelRoot>=BASE&&kernelRoot+4096n<=memoryEnd&&kernelRoot%4096n===0n); const sequence=requestSequence(phase,caseId),framePages=exactRows(last,'OS_K2160_EVIDENCE',512).slice(17,21); const finalEvidence=last.OS_K2160_EVIDENCE; assert.equal(new Set(framePages).size,4);for(const p of framePages)assert.ok(p>=BASE&&p+4096n<=memoryEnd&&p%4096n===0n); assert.deepEqual(last.OS_K2160_SOURCE,source);assert.deepEqual(last.OS_K2160_METADATA,metadata);assert.deepEqual(last.OS_K2160_JOURNAL,journal); assert.deepEqual(last.OS_K2160_HASHES.subarray(0,32),digest);assert.deepEqual(last.OS_K2160_HASHES.subarray(64,96),imageClaim); if(phase===2&&caseId===0)assert.deepEqual(last.OS_K2160_HASHES.subarray(32,64),digest); else zero(last.OS_K2160_HASHES.subarray(32,64)); const el0=checkEl0Rows(last,snapshots,programs,symbols); let priorTicks=0n,checkedRequests=0,priorState=null; for(const s of snapshots){ const e=exactRows(s,'OS_K2160_EVIDENCE',512),cpu=exactRows(s,'OS_K2160_CPU_STATE',8),stage=Number(e[1]),svc=[330,331,332].includes(stage); const ioCheckpoint=stage>=101&&stage<=116,deviceOpen=[2,3,4,9].includes(stage)||ioCheckpoint; const afterAuth=[1,2,3,4,9].includes(stage)||ioCheckpoint,afterRelease=[4,9].includes(stage); assert.equal(e[0],0x4b32313630424f54n);assert.deepEqual(e.slice(4,11),[boot,old,BigInt(phase),BigInt(caseId),key,kernelRoot,exactRows(first,'OS_K2160_EVIDENCE',512)[10]]); assert.equal(e[2],ledger(baseline,layout).pages);assert.equal(e[3],afterRelease?e[2]:0n);assert.ok(e[10]>0n); assert.equal(cpu[0],svc?exactRows(s,'OS_K2160_USER_SPACES',24)[(stage-330)*8]:kernelRoot); if(!svc)assert.equal(cpu[1],e[10]); assert.equal(cpu[2]&0x80n,0x80n);assert.equal(cpu[7],4n);assert.equal(cpu[6],e[21]||cpu[6]); assert.ok(cpu[3]>=stackLow&&cpu[3]<=stackTop&&cpu[3]%16n===0n);assert.equal(cpu[4]&0xff00ffffffn,0n); assert.ok(cpu[5]>priorTicks);priorTicks=cpu[5]; assert.deepEqual(s['kernel-root'],first['kernel-root']);assert.deepEqual(s.OS_K1000_AUTHORITY_LAYOUT_EXPECTED,first.OS_K1000_AUTHORITY_LAYOUT_EXPECTED); assert.deepEqual(s.OS_K2160_AUTHORITY,first.OS_K2160_AUTHORITY); assert.deepEqual(s.OS_K2160_SOURCE,source);assert.deepEqual(s.OS_K2160_METADATA,metadata);assert.deepEqual(s.OS_K2160_JOURNAL,journal); assert.deepEqual(s.OS_K2160_HASHES.subarray(0,32),digest);assert.deepEqual(s.OS_K2160_HASHES.subarray(64,96),imageClaim); assert.equal(e[29],afterAuth?11n:0n);assert.equal(e[11],afterAuth?1n:0n); if(svc)checkUser(s,stage-330,programs[stage===332?1:0],kernelRoot,layout,baseline,memoryEnd,symbols); else if(![2,3].includes(stage)&&!ioCheckpoint)restoredPages(baseline,s.authority,layout); else comparedPages(baseline,s.authority,layout,framePages); if(deviceOpen){assert.equal(e[15],2048n);assert.ok(e[16]>=0xa000000n&&e[16]<0xa004000n);assert.ok(e[21]>0n); for(const[name,value]of [['magic',0x74726976],['version',2],['device',2],['vendor',0x554d4551]])assert.equal(s['mmio-'+name].readUInt32LE(),value); assert.equal(s['mmio-status'].readUInt32LE(),afterRelease?0:15);assert.equal(s['mmio-ready'].readUInt32LE(),afterRelease?0:1); } if(ioCheckpoint){const seq=stage-100;assert.equal(seq,checkedRequests+1);const[op,lba]=sequence[checkedRequests]; checkReopenDmaRequest(s,seq,op,lba,diskBefore,source,metadata,journal,framePages,e[21]);checkedRequests++; } assert.equal(e[12],BigInt(checkedRequests)); assert.deepEqual(s.OS_K2160_EVIDENCE.subarray(64*8,(64+checkedRequests*16)*8),finalEvidence.subarray(64*8,(64+checkedRequests*16)*8)); zero(s.OS_K2160_EVIDENCE.subarray((64+checkedRequests*16)*8)); if(afterRelease){assert.deepEqual(e.slice(40,45),[1n,0n,1n,0n,0n]);assert.equal(e[49],1n);} else assert.deepEqual(e.slice(40,45),[0n,0n,0n,0n,0n]); if(stage===9){assert.ok(e[45]>=2n&&e[45]<=0x100ffn);assert.deepEqual(e.slice(46,48),[0n,1n]);assert.equal(e[50],0n);} if(priorState)assert.ok(stage!==priorState);priorState=stage; } assert.equal(checkedRequests,sequence.length);assert.equal(exactRows(last,'OS_K2160_EVIDENCE',512)[12],BigInt(sequence.length)); const tail=exactRows(last,'OS_K2160_EVIDENCE',512),count=phase===1?0:sequence.length; assert.deepEqual(tail.slice(22,24),phase===1?[6n,3n]:[0n,0n]); assert.deepEqual(tail.slice(24,28),phase===1?[0n,0n,0n,0n]:[BigInt(count),BigInt(count),caseId===2||caseId===3?0n:1537n,caseId===0?1n:0n]); assert.equal(tail[14],phase===1||caseId===0?0n:caseId===2?2n:caseId===3?3n:1n); assert.equal(tail[48],phase===2&&caseId!==0?1n:0n); restoredPages(first.authority,last.authority,layout); assert.equal(diskBefore.length,1024*1024);assert.equal(diskAfter.length,diskBefore.length); if(phase===1){const expected=Buffer.from(diskBefore);source.copy(expected,128*SECTOR);metadata.copy(expected,18*SECTOR);journal.copy(expected,120*SECTOR); assert.deepEqual(diskAfter,expected,'actual writer disk bytes');} else assert.deepEqual(diskAfter,diskBefore,'reader changed read-only disk'); return {scope:'K2160-independent-physical-subproof',phase,caseId,stages:snapshots.length,requests:sequence.length, imageReadOnlySegments:imageSpans.length,ownedDmaFrames:4,el0,guestAccepted:false,productAccepted:false}; } function checkedArtifact(root,ref){ assert.ok(ref&&typeof ref.path==='string'&&/^[a-f0-9]{64}$/.test(ref.sha256)); const base=realpathSync(root),path=realpathSync(resolve(base,ref.path));assert.ok(path.startsWith(base+sep),'artifact outside project'); const bytes=readFileSync(path);assert.equal(sha(bytes),ref.sha256,ref.path);return bytes; } function chosen(dtb,name){const r=spawnSync('fdtget',['-t','x',dtb,'/chosen',name],{encoding:'utf8',timeout:30000});assert.ifError(r.error);assert.equal(r.status,0,r.stderr); return r.stdout.trim().split(/\s+/).map(x=>BigInt('0x'+x));} function symbolsOf(raw){const map={};for(const line of raw.toString().split('\n')){const m=line.match(/^([a-f0-9]{16}) (?:([a-f0-9]{16}) )?[A-Za-z] (\S+)$/);if(m)map[m[3]]={address:parseInt(m[1],16),size:m[2]?parseInt(m[2],16):0};}return map;} async function loadSnapshots(root,result,candidate,elf){ const symbols=symbolsOf(checkedArtifact(root,candidate.artifacts.nm)); const stages=reopenStages(result.phase,result.caseId);assert.deepEqual(result.experimentStages.map(x=>x.stage),stages); const expectedStatic=new Set(candidate.captures),snapshots=[],imageSpans=readOnlyImageSpans(elf,candidate.imageSpan); const plan={ramStart:Number(BASE),ramEnd:Number(BASE)+result.profile.memoryMiB*1048576, allowedMmioBases:new Set(Array.from({length:32},(_,i)=>0xa000000+i*0x200)),imageSpans}; for(const record of result.experimentStages){const snapshot={},all=[...record.captures,...record.physical]; assert.deepEqual(new Set(record.captures.map(x=>x.symbol)),expectedStatic); assert.equal(record.confirmations.length,all.length); for(const[i,item]of all.entries()){ const name=item.symbol??item.name;assert.ok(!Object.hasOwn(snapshot,name),'duplicate capture '+name); if(i{ const item=record.physical[visited++];assert.ok(item,`missing derived physical span ${name}`); assert.deepEqual({name:item.name,address:item.address,size:item.size},{name,address,size}); if('mmio' in item)assert.equal(item.mmio,mmio); return snapshot[name]; }}); assert.equal(visited,record.physical.length,'extra derived physical span');snapshots.push(snapshot); } const audit=JSON.parse(checkedArtifact(root,result.captureAudit));assert.ok(Array.isArray(audit)); for(const record of result.experimentStages){ assert.equal(audit[record.auditStart]?.kind,'capture-start');assert.equal(audit[record.auditStart].stage,record.stage); assert.equal(audit[record.auditEnd-1]?.kind,'capture-end');assert.equal(audit[record.auditEnd-1].stage,record.stage); const slice=audit.slice(record.auditStart,record.auditEnd);assert.equal(slice.filter(e=>e.kind==='uart-release'&&e.stage===record.stage).length,1); assert.ok(!slice.some(e=>e.kind==='qmp-request'&&['stop','quit','system_powerdown'].includes(e.execute)),'host intervention during live capture'); } const active=audit.findIndex(e=>e.kind==='capture-start'&&e.stage===0);assert.ok(active>=0); assert.ok(!audit.slice(active).some(e=>e.kind==='qmp-request'&&['stop','quit','system_powerdown'].includes(e.execute)),'host intervention after feature activation'); return {snapshots,symbols}; } export function checkReopenShutdownProvenance(root,result){ assert.equal(result.exit?.code,0);assert.equal(result.exit?.signal,null); assert.equal(result.qmpShutdown?.guest,true);assert.equal(result.qmpShutdown?.reason,'guest-shutdown'); const transcript=JSON.parse(checkedArtifact(root,result.qmpTranscript)); assert.ok(transcript.some(r=>r.direction==='rx'&&r.message?.event==='SHUTDOWN'&&r.message.data?.guest===true&&r.message.data?.reason==='guest-shutdown')); assert.ok(!transcript.some(r=>r.direction==='tx'&&['quit','system_powerdown'].includes(r.message?.execute))); const serial=checkedArtifact(root,result.serial).toString('latin1');assert.ok(!/NATIVE-FAILED|PANIC|FATAL/.test(serial)); const captures=[...serial.matchAll(/TURKOS\/OS\/K2160: CAPTURE STAGE=0x([0-9a-f]{16})/g)].map(m=>Number(BigInt('0x'+m[1]))); const releases=[...serial.matchAll(/TURKOS\/OS\/K2160: RELEASE STAGE=0x([0-9a-f]{16})/g)].map(m=>Number(BigInt('0x'+m[1]))); assert.deepEqual(captures,reopenStages(result.phase,result.caseId));assert.deepEqual(releases,captures); const matches=[...serial.matchAll(/TURKOS\/OS\/K2160: GUEST-SYSTEM-OFF PHASE=0x([0-9a-f]{16}) CASE=0x([0-9a-f]{16}) BOOT=0x([0-9a-f]{16}) FREE_EQUAL=0x([0-9a-f]{16})/g)]; assert.equal(matches.length,1);assert.equal(BigInt('0x'+matches[0][1]),BigInt(result.phase));assert.equal(BigInt('0x'+matches[0][2]),BigInt(result.caseId)); assert.equal(BigInt('0x'+matches[0][3]),toBig(result.bootId,'bootId'));assert.equal(BigInt('0x'+matches[0][4]),1n); assert.ok(serial.indexOf(matches[0][0])>serial.lastIndexOf('TURKOS/OS/K2160: RELEASE STAGE='),'SYSTEM_OFF preceded final release'); return {guestSystemOffEvent:true,hostQuitAbsent:true}; } export async function checkReopenGuestPhysical({root,result,candidate}){ assert.equal(result.status,'GUEST_SYSTEM_OFF');assert.equal(candidate.status,'COMPILED_FEATURE_CANDIDATE'); assert.equal(candidate.milestone,'K2160');assert.equal(candidate.slug,'shutdown-native-reopen'); assert.equal(result.readOnly,result.phase===2); const command=JSON.parse(checkedArtifact(root,result.qemuCommand)); assert.equal(command.executable,'qemu-system-aarch64');assert.deepEqual(command.profile,result.profile); assert.equal(command.phase,result.phase);assert.equal(command.caseId,result.caseId);assert.equal(command.readOnly,result.readOnly); assert.equal(toBig(command.bootId,'command boot'),toBig(result.bootId,'result boot')); assert.equal(toBig(command.oldBoot,'command old boot'),toBig(result.claimedPreviousBoot,'result old boot')); assert.equal(toBig(command.seed,'command seed'),toBig(result.seed,'result seed')); for(const[option,value]of [['-dtb',result.dtb.path],['-accel','hvf'],['-cpu','host'],['-smp',String(result.profile.cpuCount)],['-m',String(result.profile.memoryMiB)]]){ assert.equal(command.argv.filter(x=>x===option).length,1,option);assert.equal(command.argv[command.argv.indexOf(option)+1],value,option); } const drives=command.argv.filter((v,i)=>command.argv[i-1]==='-drive'&&v.includes('id=k2160block,')); assert.equal(drives.length,1);assert.ok(drives[0].includes(`readonly=${result.phase===2?'on':'off'},`)); assert.ok(command.argv.includes('virtio-blk-device,drive=k2160block')); if(result.profile.route==='direct'){ assert.equal(command.argv.filter(x=>x==='-kernel').length,1); assert.equal(command.argv[command.argv.indexOf('-kernel')+1],candidate.artifacts.image.path); assert.ok(!command.argv.some(x=>x.includes('if=pflash'))); }else{ assert.equal(result.profile.route,'uefi');assert.ok(!command.argv.includes('-kernel')); assert.ok(command.argv.some(x=>x.includes('if=pflash,format=raw,readonly=on'))); assert.ok(command.argv.some(x=>x.includes('id=esp,format=raw,readonly=on'))); } for(const a of Object.values(candidate.artifacts))checkedArtifact(root,a); const userBuild=JSON.parse(checkedArtifact(root,candidate.userBuild));assert.equal(userBuild.status,'USER_BUILD_PASSED'); const programs=userBuild.programs.map(p=>checkedArtifact(root,p.image));assert.equal(programs.length,2); const elf=checkedArtifact(root,candidate.artifacts.elf),{snapshots,symbols}=await loadSnapshots(root,result,candidate,elf); const dtb=resolve(root,result.dtb.path);checkedArtifact(root,result.dtb); assert.deepEqual(chosen(dtb,'turkos,feature-experiment'),[2160n]); assert.deepEqual(chosen(dtb,'turkos,boot-id'),[BigInt('0x'+result.bootId.slice(0,8)),BigInt('0x'+result.bootId.slice(8))]); assert.deepEqual(chosen(dtb,'turkos,k2160-phase'),[BigInt(result.phase)]);assert.deepEqual(chosen(dtb,'turkos,k2160-case'),[BigInt(result.caseId)]); const wordPair=(name,value)=>assert.deepEqual([chosen(dtb,name+'-hi')[0],chosen(dtb,name+'-lo')[0]],[(value>>32n)&0xffffffffn,value&0xffffffffn]); wordPair('turkos,k2160-old',toBig(result.claimedPreviousBoot,'claimedPreviousBoot'));wordPair('turkos,k2160-seed',toBig(result.seed,'seed')); const imageClaim=Buffer.from(candidate.artifacts.image.sha256,'hex'); for(let i=0;i<8;i++)assert.deepEqual(chosen(dtb,`turkos,k2160-image-${i}`),[BigInt(imageClaim.readUInt32BE(i*4))]); const physical=checkReopenPhysicalSnapshots({snapshots,phase:result.phase,caseId:result.caseId,bootId:result.bootId, previousBoot:result.claimedPreviousBoot,seed:result.seed,memoryMiB:result.profile.memoryMiB,symbols,elf,imageSpan:candidate.imageSpan, imageSha256:candidate.artifacts.image.sha256,programs,diskBefore:checkedArtifact(root,result.beforeDisk),diskAfter:checkedArtifact(root,result.afterDisk)}); const shutdown=checkReopenShutdownProvenance(root,result); return {...physical,...shutdown,guestAccepted:false,productAccepted:false}; }