import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import {spawnSync} from 'node:child_process'; const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),tag=crypto.randomBytes(6).toString('hex'),sourceRoot=path.join(run.root,'private/receipt-composition-b4093c6f6707'),source=JSON.parse(fs.readFileSync(path.join(sourceRoot,'state.json'))),root=path.join(run.root,'private/purchasing-continuity-read-'+tag),app=path.join(root,'app'); if(!JSON.parse(fs.readFileSync(path.join(sourceRoot,'integrated-result.json'))).passed||source.env.DB_DATABASE!=='budget_core_sgf_b4093c6f6707'||source.env.DB_PORT!=='55439'||source.env.SGF_ISOLATED_REGRESSION_RUN!==run.id)throw Error('Owned completed regression book required'); fs.mkdirSync(root);for(const dir of ['app','bootstrap','config','routes','resources','database','public'])fs.cpSync(dir,path.join(app,dir),{recursive:true,filter:p=>!p.replaceAll('\\','/').includes('bootstrap/cache')});for(const pkg of ['budget-control','payables','general-ledger','module-updates','purchasing'])fs.cpSync(path.join('packages',pkg),path.join(app,'packages',pkg),{recursive:true});fs.symlinkSync(path.resolve('vendor'),path.join(app,'vendor'),'junction');fs.copyFileSync('composer.json',path.join(app,'composer.json'));for(const dir of ['bootstrap/cache','storage/logs','storage/framework/cache/data','storage/framework/views','storage/framework/sessions'])fs.mkdirSync(path.join(app,dir),{recursive:true}); // Existing bindings, native manifests and business facts remain in place; only application/session files are new. for(const file of ['fixture.json','native-fixture.json'])fs.copyFileSync(path.join(sourceRoot,file),path.join(root,file)); const env={...source.env,APP_BASE_PATH:app,SGF_DOSSIERS_QA_ENABLED:'true',SGF_PURCHASING_FOCUS_QA_ENABLED:'true',SGF_PURCHASING_CONTINUITY_QA_ENABLED:'true',SESSION_COOKIE:'sgf_dossier_read_'+tag,RECEIPT_COMPOSITION_STATE:path.join(root,'state.json')};const state={...source,root,app,env,focus:true,dossiers:true,read_overlay:true,original_root:sourceRoot};fs.writeFileSync(path.join(root,'state.json'),JSON.stringify(state,null,2)); const result=spawnSync('C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe',[path.resolve('scripts/purchasing-continuity-read-proof.php')],{cwd:app,env,encoding:'utf8',windowsHide:true,timeout:180000});fs.writeFileSync(path.join(root,'read-proof.log'),result.stdout+'\n'+result.stderr);if(result.status!==0||!fs.existsSync(path.join(root,'purchasing-continuity-read-result.json')))throw Error('Dossier read proof incomplete; private diagnostics retained '+tag);console.log(JSON.stringify({tag,root,result:result.stdout.trim()}));