import assert from'node:assert/strict'; import{copyFileSync,cpSync,readdirSync,mkdirSync,mkdtempSync,readFileSync,writeFileSync}from'node:fs'; import{join,dirname,relative}from'node:path'; import{spawnSync}from'node:child_process'; import{hashAt,frozenSnapshot}from'./boot-contract-report.mjs'; const root=process.cwd(),directory=mkdtempSync('reports/os-implementation/K2085-smp-progress-staging-local-'),source=join(directory,'source'),artifact=p=>({path:relative(root,p),sha256:hashAt(root,relative(root,p))}),report={schema:'turkos-k2085-smp-progress-preparation/v1',status:'RUNNING',guestAccepted:false,productAccepted:false,sources:[],commands:[],mutants:[],frozenBefore:frozenSnapshot(root)}; function copy(path){const to=join(source,path);mkdirSync(dirname(to),{recursive:true});copyFileSync(path,to);report.sources.push(artifact(to));} function walk(path){for(const e of readdirSync(path,{withFileTypes:true})){const child=join(path,e.name);if(e.isDirectory())walk(child);else{assert.ok(e.isFile());copy(child);}}} copyFileSync('scripts/os-acceptance/smp-progress-preparation.mjs',directory+'/harness.mjs.txt');report.harness=artifact(directory+'/harness.mjs.txt'); for(const p of['os-smp-progress/Cargo.toml','os-smp-progress/Cargo.lock','kernel/SMP_PROGRESS_CONTRACT.md'])copy(p);walk('os-smp-progress/src');walk('os-smp-progress/tests'); const env={...process.env,CARGO_TARGET_DIR:join(root,directory,'target')};delete env.RUSTFLAGS;delete env.CARGO_ENCODED_RUSTFLAGS; function run(name,args,expected){const r=spawnSync('cargo',args,{cwd:root,env,encoding:'utf8',timeout:600000,maxBuffer:16*1024*1024}),log=join(directory,name+'.log');writeFileSync(log,(r.stdout??'')+(r.stderr??''));report.commands.push({name,args,exitCode:r.status,log:artifact(log)});assert.ifError(r.error);assert.equal(r.signal,null);assert.equal(r.status,expected,name);return readFileSync(log,'utf8');} try{ const manifest=join(source,'os-smp-progress/Cargo.toml');assert.match(run('host-tests',['test','--manifest-path',manifest,'--locked','--offline','--test','progress'],0),/11 passed; 0 failed/);run('target',['check','--manifest-path',manifest,'--locked','--offline','--lib','--target','aarch64-unknown-none'],0); for(const[name,before,after,count,file,test]of[["root", "root==0||", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["binding-cpu", "b.cpu==cpu as u64&&", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["binding-generation", "b.generation!=0&&", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["binding-epoch", "&&b.epoch==first.epoch", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["worker-generation", "id.generation!=0&&", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["worker-slot", "id.slot==index as u64&&", "", 1, "progress", "os_smp_progress_invalid_configuration"], ["context-cpu", "e.cpu!=self.sample.binding.cpu||", "", 1, "progress", "os_smp_progress_context_refusal_preserves_worker"], ["context-root", "e.root!=self.root||", "", 1, "progress", "os_smp_progress_context_refusal_preserves_worker"], ["context-worker", "e.worker!=self.sample.worker||", "", 1, "progress", "os_smp_progress_context_refusal_preserves_worker"], ["context-mask", "||!e.masked", "", 1, "progress", "os_smp_progress_context_refusal_preserves_worker"], ["clock-zero", "e.counter==0||", "", 1, "progress", "os_smp_progress_clock_refusal_is_transactional"], ["clock-regression", "||e.counter