import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import {spawnSync} from 'node:child_process'; const read=p=>JSON.parse(fs.readFileSync(p,'utf8')),state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),tag=process.argv[2];if(state.port!==55439||!/^[a-f0-9]{12}$/.test(tag??''))throw Error('Owned native fixture required'); const root=path.join(state.root,'private/ledger-native-'+tag),settings=read(path.join(root,'settings.json')),artifact=read(path.join(settings.common_bundle,'manifest.json')),testRoot=path.join(root,'bundle-boot-'+crypto.randomBytes(6).toString('hex'));fs.mkdirSync(testRoot);let checks=0; for(const [name,expected] of [['modified','FINANCE_BUNDLE_FILE_MISMATCH'],['extra','FINANCE_BUNDLE_EXTRA_OR_MISSING_FILE'],['pin','FINANCE_BUNDLE_MANIFEST_MISMATCH'],['loader','FINANCE_BUNDLE_LOADER_MISMATCH']]){ const dir=path.join(testRoot,name);fs.mkdirSync(dir);for(const f of [...artifact.files.map(f=>f.file),'manifest.json']){const to=path.join(dir,f);fs.mkdirSync(path.dirname(to),{recursive:true});fs.copyFileSync(path.join(settings.common_bundle,f),to);} if(name==='modified')fs.appendFileSync(path.join(dir,'payables/bootstrap.php'),'\n// QA altered content\n');if(name==='extra')fs.writeFileSync(path.join(dir,'unexpected.txt'),'QA'); const marker=path.join(dir,'executed.txt');if(name==='loader')fs.writeFileSync(path.join(dir,'Bundle.php'),'