Files
SGF/scripts/summarize-financial-receipt.mjs
2026-11-04 09:37:20 +02:00

3 lines
3.7 KiB
JavaScript

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')),sha=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),root=path.join(state.root,'private/ledger-6070063f42f2'),out='docs/proofs/financial-receipt-recovery-20261103.json';if(state.port!==55439||fs.existsSync(out))throw Error('Fresh isolated consolidation');const evidence=['financial-receipt-cases.json','financial-receipt-core.json','financial-receipt-http.json','financial-receipt-form.json'].map(file=>{const p=path.join(root,file),v=read(p);if(!v.passed)throw Error('Invalid proof');return{file:path.relative(state.root,p).replaceAll('\\','/'),sha256:sha(p),result:v};});if(evidence.map(e=>e.result.checks).join()!=='13,6,19,5')throw Error('Missing checks');let preserved=0;const priors=['docs/proofs/ledger-receipt-recovery-20261103.json','docs/proofs/common-ledger-industrial-correction-20261103.json'];for(const file of priors)for(const e of read(file).private_evidence){if(sha(path.join(state.root,e.file))!==e.sha256)throw Error('Prior evidence changed');preserved++;}for(const [tag,pin] of [['760a92655dc1','6a507ea7d708a12a8e526e4c610696d8db84079d18aede470237b65505630e7e'],['b06aa4315783','cbc4ddbea15f5e396c92bc2e664b973138551928980f334bcf3eb0cf097cacb1']]){const r=path.join(state.root,'private/finance-bundle-'+tag);if(sha(path.join(r,'manifest.json'))!==pin)throw Error('Frozen bundle changed');for(const f of read(path.join(r,'manifest.json')).files)if(sha(path.join(r,f.file))!==f.sha256)throw Error('Frozen runtime changed');}
const files=['packages/payables/src/ReceiptReader.php','packages/payables/src/Payables.php','packages/payables/src/SupplierSettlements.php','packages/payables/bootstrap.php','app/Modules/Accounting/GeneralLedger.php','app/Modules/Accounting/GeneralLedgerController.php','routes/web.php','resources/views/accounting/receipt-recovery.blade.php','scripts/ledger-composition-proof.php','scripts/financial-receipt-proof.php','scripts/financial-receipt-core.php','scripts/financial-receipt-http.mjs','scripts/financial-receipt-form.mjs','scripts/summarize-financial-receipt.mjs','docs/FINANCIAL_RECEIPT_RECOVERY_DELIVERY.md','docs/GENERAL_LEDGER_RECEIPT_RECOVERY_DELIVERY.md','README.md'];for(const f of files){if(f.endsWith('.blade.php')||(!f.endsWith('.php')&&!f.endsWith('.mjs')))continue;const p=f.endsWith('.php'),r=spawnSync(p?'C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe':process.execPath,[p?'-l':'--check',f],{encoding:'utf8',windowsHide:true});if(r.status)throw Error('Syntax '+f);}if(spawnSync('git',['diff','--check'],{encoding:'utf8',windowsHide:true}).status)throw Error('Diff check');fs.writeFileSync(out,JSON.stringify({increment:'FINANCIAL-RECEIPT-RECOVERY-v1',date:new Date().toISOString(),functional_code:true,checks:43,private_evidence:evidence,previous_manifests:priors.map(file=>({file,sha256:sha(file)})),previous_private_artifacts_verified:preserved,frozen_packages_bytes_preserved:true,sources:files.map(file=>({file,sha256:sha(file)})),fixture:{actual_supplier_recognition:true,settlement_receipt_infrastructure_only:true,settlement_fixture_represents_no_business_effect:true,payments:0},preservation:{six_records_untouched:true,blocked_cache_untouched:true,prior_demos_not_reset:true,no_real_grants:true,no_migrations:true,no_purchasing_activation:true,no_publication:true,no_checkpoint:true},limits:{visual_review_pending:true,sustained_load_validated:false,deployment_capacity_validated:false,no_sgc_installation:true}},null,2));console.log(JSON.stringify({output:out,checks:43,prior_artifacts_verified:preserved}));