import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import assert from 'node:assert/strict'; const tag=process.argv[2];assert(/^[a-f0-9]{12}$/.test(tag??''));const state=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),root=path.join(state.root,'private','requisition-composition-'+tag),hash=f=>crypto.createHash('sha256').update(fs.readFileSync(f)).digest('hex'),out='docs/proofs/requisition-composition-20261103.json';assert(!fs.existsSync(out)); const tests={};for(const [name,file,count]of [['workflow','result.json',17],['guards','security-final.json',16],['navigation','navigation-final.json',11]]){const p=path.join(root,file),value=JSON.parse(fs.readFileSync(p));assert.equal(value.passed,true);assert.equal(value.checks.length,count);tests[name]={file:'private/requisition-composition-'+tag+'/'+file,sha256:hash(p),checks:count,result:value};} const ui='docs/proofs/requisition-home-20261103.json',u=JSON.parse(fs.readFileSync(ui));assert(u.passed&&u.checks===6);tests.ui={file:ui,sha256:hash(ui),checks:u.checks,result:u}; const sources=['app/Modules/Purchasing/InternalRequisitionQa.php','config/internal_requisitions.php','app/Providers/AppServiceProvider.php','app/Shared/Context/ModuleNavigation.php','app/Modules/Identity/Services/IdentityWorkflow.php','app/Modules/Identity/Http/RequireCompanyContext.php','resources/js/PurchasingHome.jsx'].map(file=>({file,sha256:hash(file)})); const bundle=path.join(root,'bundle'),m=JSON.parse(fs.readFileSync(path.join(bundle,'manifest.json')));for(const [file,pin]of Object.entries(m.files)){assert.equal(hash(path.join(bundle,file)),pin);assert.equal(hash(path.join('../compras',file)),pin);assert.equal(hash(path.join(state.root,'development-app/packages/internal-requisitions',file)),pin);sources.push({file:'../compras/'+file,sha256:pin});} const pointer='packages/purchasing/current.json',p=JSON.parse(fs.readFileSync(pointer));assert.equal(p.version,'0.1.1');assert.equal(p.manifest_sha256,'91ba35ee3aa1ca226052c94ed682e430cb7870beb241f16b17d889046e1f711d'); const prior=['docs/proofs/internal-requisitions-sgf.json','docs/proofs/module-matrix-audit-complete-20261103.json','docs/proofs/sgf-demo-8039-reconciliation.json'].map(file=>({file,sha256:hash(file)})); fs.writeFileSync(out,JSON.stringify({date:new Date().toISOString(),increment:'SGF-REQUISITION-COMPOSITION-QA-v1',functional_code:true,passed:true,checks:50,tests,sources,bundle_manifest_sha256:hash(path.join(bundle,'manifest.json')),shared_source_matches_current8039_bundle:true,installed_purchasing_pointer:{version:p.version,sha256:hash(pointer)},prior_proofs_preserved:prior,limitations:['Only the isolated budget-testing composition is mounted; normal destination remains disabled.','One selected lifecycle, not a repeated full procurement or cross-company regression.','The QA runtime role owns its new database; owner/runtime deployment separation is not validated.','No visual review, sustained load or deployment capacity validated.','Receipt preparation/confirmation in SGF remains pending.'],preservation:{existing_databases_migrated:false,existing_demos_written:false,protected_six_records_written:false,blocked_cache_cleared:false,real_or_public_rights_changed:false,purchasing_candidate_activated_at_destination:false,publication:false,checkpoint:false}},null,2));console.log(JSON.stringify({passed:true,checks:50,output:out}));