// A single deferred component run after the K2100 guest sequence has stopped. // No milestone/roadmap promotion. A failed predecessor remains failed. import assert from 'node:assert/strict'; import {readFileSync,writeFileSync,renameSync,mkdtempSync,copyFileSync,existsSync,statfsSync} from 'node:fs'; import {spawn,spawnSync} from 'node:child_process'; import {createHash} from 'node:crypto'; import {join,relative} from 'node:path'; import {fileURLToPath} from 'node:url'; import {setTimeout as delay} from 'node:timers/promises'; const [sequencePath,candidatePath]=process.argv.slice(2);assert.ok(sequencePath&&candidatePath&&process.argv.length===4); const read=p=>JSON.parse(readFileSync(p)),artifact=path=>({path,sha256:createHash('sha256').update(readFileSync(path)).digest('hex')}); const directory=mkdtempSync('reports/os-implementation/K2150-native-component-queue-'); copyFileSync(fileURLToPath(import.meta.url),join(directory,'harness.mjs.txt')); const candidate=read(candidatePath);assert.equal(candidate.slug,'shutdown-native-flush');assert.equal(candidate.status,'COMPILED_FEATURE_CANDIDATE'); const pins=[artifact(candidatePath),...Object.values(candidate.artifacts),...Object.values(candidate.sources),candidate.spec,candidate.harness, ...['k2150-native-guest-runner.mjs','k2150-native-storage-fixture.mjs','k2150-native-component-check-v2.mjs','features/k2150-native-check.mjs', 'paused-capture-qmp.mjs','dma-gdb.mjs','dma-network.mjs','file-map-disk.mjs'].map(p=>artifact('scripts/os-acceptance/'+p))]; const statePath='reports/os-implementation/active-development-continuation.json'; function atomic(path,data){writeFileSync(path+'.native-tmp',JSON.stringify(data,null,2)+'\n');renameSync(path+'.native-tmp',path);} function verify(){for(const pin of pins)assert.deepEqual(artifact(pin.path),pin);} function save(status,extra={}){ const report={status,guestAccepted:false,productAccepted:false,scope:'Deferred actual-storage component only. The EL0 shutdown integration and K2150 admission remain pending.', sequencePath,candidate:artifact(candidatePath),pins,...extra}; atomic(join(directory,'report.json'),report); const state=read(statePath);Object.assign(state.K2150,{nativeComponentQueue:join(directory,'report.json'),nativeComponentStatus:status,...extra}); state.updatedAt=new Date().toISOString();atomic(statePath,state); } async function run(executable,args,log){ const child=spawn(executable,args,{stdio:['ignore','pipe','pipe'],env:{...process.env,FX_PROFILES:'all'}});let output=''; for(const stream of [child.stdout,child.stderr])stream.on('data',bytes=>{output+=bytes;writeFileSync(log,output);}); const code=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('exit',resolve);}); assert.equal(code,0,'command failed; preserved log: '+log);return output; } writeFileSync('/tmp/turkos-k2150-native-queue.txt',directory+'\n'); let matrix; try{ verify();save('NATIVE_STORAGE_COMPONENT_WAITING');console.log('NATIVE-QUEUE '+directory); let sequence; for(;;){ sequence=read(sequencePath);assert.ok(['PROFILE_COLLECTION_ACTIVE','LONG_WORKLOAD_PROFILE_COMPONENTS_PASSED','LONG_WORKLOAD_PROFILE_SEQUENCE_FAILED'].includes(sequence.status)); if(sequence.status!=='PROFILE_COLLECTION_ACTIVE')break; await delay(30000); } verify(); const processes=spawnSync('ps',['-axo','pid=,comm='],{encoding:'utf8'});assert.equal(processes.status,0); assert.ok(!processes.stdout.split('\n').some(l=>l.trim().endsWith('qemu-system-aarch64')),'one guest lane only'); const disk=statfsSync('.');assert.ok(disk.bavail*disk.bsize>1.5*1024**3); save('NATIVE_STORAGE_COMPONENT_RUNNING',{predecessorSequenceStatus:sequence.status}); const output=await run('node',['scripts/os-acceptance/k2150-native-guest-runner.mjs',candidatePath],join(directory,'native-guest.log')); const terminal=JSON.parse(output.trim().split('\n').at(-1));assert.equal(terminal.status,'RUNNER_PASSED');matrix=terminal.matrix; verify(); const result=JSON.parse((await run('node',['scripts/os-acceptance/k2150-native-component-check-v2.mjs',matrix,candidatePath],join(directory,'physical-check.log'))).trim().split('\n').at(-1)); assert.equal(result.status,'NATIVE_STORAGE_PHYSICAL_COMPONENT_PASSED'); save('NATIVE_STORAGE_PHYSICAL_COMPONENT_PASSED',{nativePhysicalComponent:result.report,matrix}); }catch(error){ save('NATIVE_STORAGE_PHYSICAL_COMPONENT_FAILED',{error:error.stack,matrix:matrix??null});console.error(error.stack);process.exitCode=1; } // Publish both successful and failed component evidence when the queue ran. try{ for(const deadline=Date.now()+1800000;existsSync('reports/site-publication/publish.lock');){assert.ok(Date.now()