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

22 lines
4.9 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';
const read=p=>JSON.parse(fs.readFileSync(p,'utf8').replace(/^\uFEFF/,''));
const hash=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
const state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json');if(state.port!==55439)throw Error('Owned QA host required');
const history=path.join(state.root,'private/payable-history-03e16d9fb37d'),settlements=path.join(state.root,'private/settlement-page-dbd466ae44a5');
const before=read(path.join(history,'report-volume.json')),after=read(path.join(history,'report-volume-batch.json')),cases=read(path.join(history,'report-cases-batch.json')),book=read(path.join(settlements,'report-settlements.json')),http=read(path.join(settlements,'report-http.json'));
const postHistory=read(path.join(history,'report-post.json')),postBook=read(path.join(settlements,'report-post.json'));
if([before,after,cases,book,http,postHistory,postBook].some(p=>!p.passed)||cases.cases.some(c=>!c.passed))throw Error('Incomplete report proof');
for(const key of ['totals','known_positions','positions_sha256','windows'])if(JSON.stringify(before.report[key])!==JSON.stringify(after.report[key]))throw Error('Optimisation changed report content');
if(after.report.totals.count!==10000||after.report.windows!==100||after.writer_lock_queries!==0||!postBook.business_fingerprint_equal||!postHistory.business_fingerprint_equal)throw Error('Preservation or complete report failed');
const prior='docs/proofs/sgf-settlement-read-isolation-20261102.json';for(const p of read(prior).evidence)if(hash(path.join(state.root,p.file))!==p.sha256)throw Error('Previous read proof changed');
const files=['packages/payables/src/Payables.php','app/Modules/Purchasing/SupplierPayables.php','app/Modules/Purchasing/SupplierPayablesController.php','app/Modules/Purchasing/SupplierPayableReportController.php','packages/payables/ui/page.php','resources/views/purchasing/payable-report.blade.php','routes/web.php','scripts/payable-history-sgf-proof.php','scripts/payable-report-proof.php','scripts/payable-report-http.mjs','scripts/payable-report-http-router.php','scripts/summarize-payable-report.mjs'];
const evidence=[];for(const [root,names] of [[history,['report-volume.json','report-volume-batch.json','report-cases.json','report-cases-batch.json','report-post.json']],[settlements,['report-settlements.json','report-http.json','report-http-mode.json','report-post.json']]])for(const name of names)evidence.push({file:path.relative(state.root,path.join(root,name)).replaceAll('\\','/'),sha256:hash(path.join(root,name))});
const result={increment:'SGF-PAYABLE-POSITION-REPORT-SIM-v1',date:'2026-11-02',synthetic_only:true,tests:cases,settlement_book:book,http,measurements:{before,after},postchecks:{historical_book:postHistory,settlement_book:postBook},
conditions:{php:'8.4.27',memory_limit:'512M',same_database_and_filter:true,independent_php_processes:true,one_valid_sample_per_implementation:true,warm_local_database:true,other_local_processes_not_controlled:true,indices_added:false,comparison:'Two implementations of the complete 10000-position report, not the older page or settlement benchmarks.'},
sources:files.map(file=>({file,sha256:hash(file)})),evidence,previous_proof:{file:prior,sha256:hash(prior),private_evidence_hashes_preserved:true},
accounting_next:{state:'specification_only_authorisation_pending',file:'docs/GENERAL_LEDGER_FIRST_SYNTHETIC_SCOPE.md',sha256:hash('docs/GENERAL_LEDGER_FIRST_SYNTHETIC_SCOPE.md'),functional_code:false,new_rights_granted:false},
limits:['The complete 10000-position report still took 12.558 seconds in one local sample; sustained load and deployment capacity not validated.','Current position only. No historical cutoff, archived report recovery, bank reconciliation, general ledger or accounting recognition added.','The new core positionsPage reuses the existing calculation and skips presentation-only evidence pages. Each keyset window selects at most 100 sources; memory is bounded to window data and accumulators, not the full universe. A single very large history can still be material.','Remaining cost has not been isolated by profiling. Do not attribute it to a particular index or claim an index gain.'],
six_pending_associations_untouched:true,blocked_cache_untouched:true,new_operational_rights:false,migration_in_destination:false,native_activation:false,publication:false,checkpoint:false,visual_review_pending:true,deployment_capacity_validated:false};
fs.writeFileSync('docs/proofs/sgf-payable-report-20261102.json',JSON.stringify(result,null,2)+'\n');
console.log(JSON.stringify({cases:cases.cases.length,assertions:cases.assertions,http_checks:http.checks,positions:after.report.totals.count,before_ms:before.time_ms,after_ms:after.time_ms,queries_before:before.queries,queries_after:after.queries,content_equal:true,accounting_implementation_authorised:false}));