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

12 lines
3.9 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'),output='docs/proofs/common-finance-bundle-20261103.json';if(state.port!==55439||fs.existsSync(output))throw Error('Fresh owned consolidation required');
const artifact=read(path.join(state.root,'finance-bundle-latest.json')),checks=read(path.join(state.root,'finance-bundle-check-latest.json')),boot=read(path.join(state.root,'finance-bundle-boot-latest.json')),nativeRoot=path.join(state.root,'private/ledger-native-55e7c1ae0543'),teamRoot=path.join(state.root,'private/ledger-native-6873db67a6a7');
const runtime=read(path.join(nativeRoot,'finance-bundle-proof.json')),team=read(path.join(teamRoot,'ledger-cycle-demo-http.json'));if(![checks,boot,runtime,team].every(x=>x.passed))throw Error('Incomplete valid proofs');
const manifest=read(path.join(artifact.root,'manifest.json'));if(sha(path.join(artifact.root,'manifest.json'))!==artifact.manifest_sha256)throw Error('Pinned artifact changed');for(const f of manifest.files)if(sha(path.join(artifact.root,f.file))!==f.sha256)throw Error('Artifact changed');
const priorPath='docs/proofs/common-ledger-complete-cycle-20261102.json',prior=read(priorPath);for(const f of prior.private_evidence)if(sha(path.join(state.root,f.file))!==f.sha256)throw Error('Prior evidence changed');
const sources=['packages/finance-bundle/Bundle.php','scripts/finance-bundle-build.mjs','scripts/finance-bundle-check.mjs','scripts/finance-bundle-boot-check.mjs','scripts/summarize-finance-bundle.mjs','scripts/payable-history-sgf-proof.php','scripts/ledger-cycle-native-proof.php','scripts/ledger-cycle-native-run.mjs','../compras/app/Services/FinanceBundle.php','../compras/app/Providers/AppServiceProvider.php','../compras/config/common-finance-bundle.php','docs/COMMON_FINANCE_BUNDLE_DELIVERY.md','docs/GENERAL_LEDGER_SALES_RECEIVABLE_SCOPE.md'];let php=0,js=0;
for(const f of sources){if(!f.endsWith('.php')&&!f.endsWith('.mjs'))continue;const isPhp=f.endsWith('.php'),r=spawnSync(isPhp?'C:/laragon/tools/sgf-tempo/php-8.4.27/php.exe':process.execPath,[isPhp?'-l':'--check',f],{encoding:'utf8',windowsHide:true});if(r.status!==0)throw Error('Syntax failed '+f);isPhp?php++:js++;}
const files=[path.join(nativeRoot,'finance-bundle-proof.json'),path.join(checks.root,'proof.json'),path.join(boot.root,'proof.json'),path.join(teamRoot,'ledger-cycle-demo-http.json')];
const result={increment:'COMMON-FINANCE-BUNDLE-QA-v1',consolidated_at_utc:new Date().toISOString(),functional_packaging_code:true,artifact:{files:manifest.files.length,manifest_sha256:artifact.manifest_sha256,source_packages:['payables','general-ledger'],no_credentials_or_fixture_data:true},tests:{runtime,integrity:checks,host_boot:boot,team_readiness:team,syntax:{php,js},native_phpstan:{level:7,files:2,errors:0},pint:true},evidence:files.map(f=>({file:path.relative(state.root,f).replaceAll('\\','/'),sha256:sha(f)})),previous_proof:{file:priorPath,sha256:sha(priorPath),private_artifacts_verified:prior.private_evidence.length},sources:sources.map(file=>({file,sha256:sha(file)})),demo:read(path.join(teamRoot,'ledger-demo.json')),limits:{full_application_distribution:false,operational_installation:false,visual_review_pending:true,deployment_capacity_validated:false,publishing:false,purchasing_activation:false,real_access_changes:false,checkpoint:false},preserved:{six_pending_associations:true,blocked_cache:true,existing_demos:true,previous_valid_proofs:true}};
fs.writeFileSync(output,JSON.stringify(result,null,2)+'\n');console.log(JSON.stringify({output,runtime_checks:runtime.checks,integrity_checks:checks.checks,host_refusals:boot.checks,demo_checks:team.checks,syntax:result.tests.syntax,previous_private_artifacts_verified:prior.private_evidence.length}));