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'),tag=process.argv[2]; if(state.port!==55439||!/^[a-f0-9]{12}$/.test(tag??''))throw Error('Owned QA tag required'); const root=path.join(state.root,'private/settlement-page-'+tag),owned=read(path.join(root,'settings.json')); if(owned.tag!==tag||owned.cluster!=='sgf_modular_regression_'+state.id)throw Error('Wrong owned context'); const tests=read(path.join(root,'settlement-cases.json')),http=read(path.join(root,'settlement-http.json')),post=read(path.join(root,'settlement-post.json')),nav=read(path.join(root,'settlement-nav.json')),volume=read(path.join(root,'settlement-volume.json')); if(!tests.passed||tests.cases.some(c=>!c.passed)||!http.passed||!post.passed||!post.baseline_fingerprint_equal||!nav.passed)throw Error('Incomplete proof'); const measurements=Object.fromEntries(['legacy','page25','page100','focus'].map(name=>[name,read(path.join(root,'settlement-bench-'+name+'.json'))])); for(const size of [25,100])for(const table of ['payments','proposals','allocations','events'])if(measurements.legacy.window_fingerprints[table][size]!==measurements['page'+size].window_fingerprints[table][size])throw Error('Window parity failed'); if(measurements.legacy.original_payment_fingerprint!==measurements.focus.original_payment_fingerprint||measurements.focus.original_unallocated_minor!==41)throw Error('Full-history amount differs'); if(Object.values(measurements).some(m=>m.indices_added||m.volume!==1000))throw Error('Measurement conditions differ'); const prior='docs/proofs/sgf-payable-evidence-focus-20261102.json';for(const p of read(prior).prior_proofs_preserved)if(hash(p.file)!==p.sha256)throw Error('Previous proof changed'); const files=['packages/payables/src/SupplierSettlements.php','packages/payables/src/SettlementHttp.php','packages/payables/ui/settlements.php','packages/payables/ui/settlement-navigation.php','packages/payables/ui/settlement-allocations.php','app/Modules/Purchasing/SupplierPaymentsController.php','scripts/payable-history-sgf-proof.php','scripts/settlement-page-run.mjs','scripts/settlement-page-proof.php','scripts/settlement-page-cases.php','scripts/settlement-page-bench.mjs','scripts/settlement-page-http.mjs','scripts/settlement-page-http-router.php','scripts/summarize-settlement-page.mjs']; const evidence=['settlement-fixture.json','settlement-volume.json','settlement-cases.json','settlement-http.json','settlement-nav.json','settlement-post.json',...Object.keys(measurements).map(k=>'settlement-bench-'+k+'.json')].map(file=>({file:'private/settlement-page-'+tag+'/'+file,sha256:hash(path.join(root,file))})); const result={increment:'SGF-SETTLEMENT-PAGED-READ-SIM-v1',date:'2026-11-02',synthetic_only:true,tests,http,navigation_supplement:nav,preservation:post,volume,measurements, conditions:{php:'8.4.27',memory_limit:'512M',independent_process_per_strategy:true,warmup:'Same original-payment focus query before each strategy',samples_per_strategy:1,order:['legacy','page25','page100','focus'],memory:'PHP allocated heap peak, not process RSS',index_experiments:false,benchmark_workflow:'One payment, 60 allocations and one integral reversal through common commands; 999 explicit benchmark payment clones. 61 synthetic source obligations. Not 1000 fully executed purchase/payment workflows.'}, sources:files.map(file=>({file,sha256:hash(file)})),evidence,prior_proofs_preserved:[{file:prior,sha256:hash(prior)}], limits:['Only SGF explicitly opts into the bounded reader. Native installed package, legacy default and demos unchanged.','Read authorization still uses the existing writer locks; no throughput or lock-contention improvement established.','Counts and filters still perform database work over matching rows. Only 1000 settlement payments measured; do not merge these numbers with the earlier 1000/5000/10000 source-document benchmarks.','Snapshots are per request; there is no frozen snapshot across human pagination. Commands revalidate current facts and allocation cycle.','No live SGF historical source, operational financial cutover, bank execution, reconciliation or accounting added.'], six_pending_associations_untouched:true,blocked_cache_untouched:true,new_operational_rights:false,operational_migrations:false,purchasing_candidate_activation:false,publication:false,checkpoint:false,visual_review_pending:true,deployment_capacity_validated:false}; fs.writeFileSync('docs/proofs/sgf-settlement-paged-read-20261102.json',JSON.stringify(result,null,2)+'\n'); console.log(JSON.stringify({cases:tests.cases.length,assertions:tests.assertions,http_checks:http.checks,queries_before:measurements.legacy.queries,queries_after:measurements.page25.queries,financial_fingerprint_preserved:true}));