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

2 lines
2.8 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import {spawnSync} from 'node:child_process';
const state=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json','utf8')),root=path.join(state.root,'private/ledger-922dac0c0596'),read=p=>JSON.parse(fs.readFileSync(p,'utf8')),sha=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),output='docs/proofs/ledger-receipt-recovery-20261103.json';if(state.port!==55439||fs.existsSync(output))throw Error('Fresh isolated evidence only');const evidence=['ledger-receipt-cases.json','receipt-http-final.json','receipt-form.json'].map(file=>{const p=path.join(root,file),v=read(p);if(!v.passed)throw Error('Incomplete proof');return{file:path.relative(state.root,p).replaceAll('\\','/'),sha256:sha(p),result:v};});if(evidence.map(e=>e.result.checks).join()!=='10,16,3')throw Error('Missing checks');const prior='docs/proofs/common-ledger-industrial-correction-20261103.json';let verified=0;for(const e of read(prior).private_evidence){if(sha(path.join(state.root,e.file))!==e.sha256)throw Error('Prior evidence changed');verified++;}const sources=['packages/general-ledger/src/PayableJournal.php','app/Modules/Accounting/GeneralLedger.php','app/Modules/Accounting/GeneralLedgerController.php','routes/web.php','scripts/ledger-cost-proof.php','scripts/ledger-receipt-proof.php','scripts/ledger-receipt-http.mjs','resources/views/accounting/receipt-recovery.blade.php',...['general-ledger','cost-ledger','sales-ledger','industrial-ledger','ledger-composition'].map(n=>'resources/views/accounting/'+n+'.blade.php'),'docs/GENERAL_LEDGER_RECEIPT_RECOVERY_DELIVERY.md','README.md'];for(const f of sources){if(f.endsWith('.blade.php')||(!f.endsWith('.php')&&!f.endsWith('.mjs')))continue;const php=f.endsWith('.php'),r=spawnSync(php?'C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe':process.execPath,[php?'-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(output,JSON.stringify({increment:'LEDGER-RECEIPT-RECOVERY-v1',date:new Date().toISOString(),functional_code:true,checks:29,private_evidence:evidence,previous_manifest:{file:prior,sha256:sha(prior),private_artifacts_verified:verified},sources:sources.map(file=>({file,sha256:sha(file)})),preservation:{old_demos_not_reset:true,six_records_untouched:true,blocked_cache_untouched:true,no_real_grants:true,no_migrations:true,no_publication:true,no_checkpoint:true},limits:{visual_review_pending:true,sustained_load_validated:false,deployment_capacity_validated:false,read_only_receipt_not_current_source_conference:true}},null,2));console.log(JSON.stringify({output,checks:29,previous_artifacts_verified:verified}));