// Runs only under the Python queue's held ARM64 lane and disk reservation. import assert from 'node:assert/strict'; import {spawn} from 'node:child_process'; import {readFileSync,writeFileSync,renameSync} from 'node:fs'; import {join} from 'node:path'; import {createHash} from 'node:crypto'; const [candidate,directory]=process.argv.slice(2);assert.equal(process.argv.length,4); const artifact=path=>({path,sha256:createHash('sha256').update(readFileSync(path)).digest('hex')}); const report={status:'NATIVE_POSITIVE_RUNNING',guestAccepted:false,productAccepted:false,positiveMatrixOnly:true,candidate:artifact(candidate),steps:[]}; function save(){const path=join(directory,'execution.json');writeFileSync(path+'.tmp',JSON.stringify(report,null,2)+'\n');renameSync(path+'.tmp',path);} async function run(name,args,selection){ const child=spawn('node',args,{stdio:['ignore','pipe','pipe'],env:{...process.env,FX_PROFILES:selection}});let log=''; for(const stream of [child.stdout,child.stderr])stream.on('data',b=>{log+=b;writeFileSync(join(directory,name+'.log'),log);}); const code=await new Promise((done,fail)=>{child.once('error',fail);child.once('exit',done);}); report.steps.push({name,args,selection,exitCode:code,log:artifact(join(directory,name+'.log'))});save(); assert.equal(code,0,'DMA component step failed: '+name); return JSON.parse(log.trim().split('\n').at(-1)); } try{ save(); const queuePath=join(directory,'report.json'),queue=JSON.parse(readFileSync(queuePath)); queue.status='NATIVE_POSITIVE_RUNNING';queue.executionPath=join(directory,'execution.json'); writeFileSync(queuePath+'.running',JSON.stringify(queue,null,2)+'\n');renameSync(queuePath+'.running',queuePath); const statePath='reports/os-implementation/active-development-continuation.json',state=JSON.parse(readFileSync(statePath)); state.K2155.nativePositiveQueueStatus='NATIVE_POSITIVE_RUNNING';state.updatedAt=new Date().toISOString(); writeFileSync(statePath+'.native-positive-running',JSON.stringify(state,null,2)+'\n');renameSync(statePath+'.native-positive-running',statePath); for(const selection of ['smoke','all']){ const guest=await run(selection+'-guest',['scripts/os-acceptance/k2155-native-guest-runner.mjs',candidate],selection); assert.equal(guest.status,'RUNNER_PASSED'); report.steps.at(-1).matrix=guest.matrix;save(); const proof=await run(selection+'-proof',['scripts/os-acceptance/k2155-native-matrix-check.mjs',guest.matrix,candidate],selection); assert.equal(proof.status,'NATIVE_POSITIVE_MATRIX_VALIDATED'); const checked=JSON.parse(readFileSync(proof.report));assert.equal(checked.guestAccepted,false);assert.equal(checked.physicalIntegratedShutdownVerified,true); assert.equal(checked.fullHardwareMatrix,selection==='all'); report.steps.at(-1).proof=artifact(proof.report);save(); } report.status='NATIVE_POSITIVE_SEQUENCE_PASSED';report.physicalIntegratedShutdownVerified=true;report.realFailureMatrixVerified=false; }catch(error){report.status='NATIVE_POSITIVE_SEQUENCE_FAILED';report.error=error.stack;process.exitCode=1;} save();console.log(JSON.stringify({status:report.status,report:join(directory,'execution.json')}));