import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import {createHash} from 'node:crypto'; const root=path.resolve('.qa/live-delivery-x'),manifestFile=path.join(root,'MANIFEST.json'); assert.equal(fs.existsSync(manifestFile),false,'Never overwrite sealed experiment evidence.'); const files=[]; const walk=relative=>{for(const entry of fs.readdirSync(path.join(root,relative),{withFileTypes:true})){ const name=path.posix.join(relative,entry.name),file=path.join(root,name),stat=fs.lstatSync(file); assert.equal(stat.isSymbolicLink(),false);assert.equal(stat.nlink,1); if(entry.isDirectory()){walk(name);continue;} assert.equal(entry.isFile(),true);const bytes=fs.readFileSync(file); files.push({path:name,bytes:bytes.length,sha256:createHash('sha256').update(bytes).digest('hex')}); }}; walk('');files.sort((a,b)=>a.path.localeCompare(b.path)); const manifest={schemaVersion:1,sample:'X',files,filesCount:files.length,totalBytes:files.reduce((sum,row)=>sum+row.bytes,0), note:'Lengths and hashes of original files, excluding this manifest. Completeness is not a delivery-success claim.'}; fs.writeFileSync(manifestFile,JSON.stringify(manifest,null,2)+'\n',{flag:'wx'}); for(const row of files){const bytes=fs.readFileSync(path.join(root,row.path));assert.equal(bytes.length,row.bytes);assert.equal(createHash('sha256').update(bytes).digest('hex'),row.sha256);} console.log(JSON.stringify({success:true,files:files.length,bytes:manifest.totalBytes,manifestFile,realModelRequests:0}));