import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { batch, sha } from './common.mjs'; const destination = path.resolve('docs/live-delivery-ab-evidence'); assert.equal(fs.existsSync(destination), false); assert.equal(JSON.parse(fs.readFileSync(path.join(batch, 'final-summary.json'))).passed, true); const sourceRoot = path.join(batch, 'node/expense-project'), bundleFile = path.join(batch, 'node/baseline.bundle'); assert.equal(fs.existsSync(bundleFile), false); execFileSync('git', ['-C', sourceRoot, 'bundle', 'create', bundleFile, '--all'], { windowsHide: true }); const verifiedBundle = execFileSync('git', ['-C', sourceRoot, 'bundle', 'verify', bundleFile], { windowsHide: true, encoding: 'utf8' }); fs.writeFileSync(path.join(batch, 'node/bundle-verification.txt'), verifiedBundle, { flag: 'wx' }); fs.cpSync(batch, destination, { recursive: true, errorOnExist: true, filter: file => file !== sourceRoot && !file.startsWith(sourceRoot + path.sep) }); fs.cpSync('scripts/live-ab', path.join(destination, 'drivers'), { recursive: true, errorOnExist: true }); for (const name of ['payload.mjs', 'inspector.mjs', 'state.mjs']) { const file = path.join(destination, 'shared-aa-drivers', name); fs.mkdirSync(path.dirname(file), { recursive: true }); fs.copyFileSync('scripts/live-aa/' + name, file, fs.constants.COPYFILE_EXCL); } const files = []; function walk(relative) { for (const entry of fs.readdirSync(path.join(destination, relative), { withFileTypes: true })) { const name = path.posix.join(relative, entry.name), file = path.join(destination, 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: sha(bytes) }); } } walk(''); files.sort((a, b) => a.path.localeCompare(b.path)); const manifest = { schemaVersion: 1, sample: 'AB-1.25.3-DeepSeek-low-engineering', files, filesCount: files.length, totalBytes: files.reduce((sum, row) => sum + row.bytes, 0), excluded: ['node/expense-project live Git checkout and generated dist: original files, exact baseline commit bundle, original index/working-copy states, after-source and checks are archived separately.'], note: 'Preserves original length failure and unexecuted React/Python/Purge. Inventory completeness is not engineering success.' }; fs.writeFileSync(path.join(destination, 'MANIFEST.json'), JSON.stringify(manifest, null, 2) + '\n', { flag: 'wx' }); console.log(JSON.stringify({ success: true, directory: destination, files: files.length, bytes: manifest.totalBytes, manifestSha256: sha(fs.readFileSync(path.join(destination, 'MANIFEST.json'))) }));