import fs from 'node:fs'; import crypto from 'node:crypto'; // Reads existing sanitised proofs only. No application, runtime or DB connection. const read=p=>JSON.parse(fs.readFileSync(p,'utf8').replace(/^\uFEFF/,'')); const sha=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'); const prefix='docs/proofs/module-association-'; const http=read(prefix+'http-lock-summary-20261102.json'); const checked=[http.proof,...http.previous_proofs]; for(const p of checked)if(sha(p.path)!==p.sha256)throw Error('Prior evidence changed: '+p.path); if(sha('app/Modules/Identity/Services/ModuleAssociationReview.php')!==http.source_sha256 ||sha('app/Modules/Identity/Http/ModuleRecordsController.php')!==http.controller_sha256)throw Error('Current source differs from HTTP evidence'); const a=read(prefix+'optimization-comparison-20261102.json'); const projection=read(prefix+'projection-summary-20261102.json'); const concurrent=read(prefix+'concurrency-summary-20261102.json'); const release=read(prefix+'release-summary-20261102.json'); if(projection.source.final_sha256!==http.source_sha256||concurrent.source_sha256!==http.source_sha256||release.source_sha256!==http.source_sha256)throw Error('Source provenance mismatch'); const variants=['baseline','batch','indexed_batch']; const coverage=[],missing=[];let complete=0,limited=0; for(const volume of [1000,5000,10000]){ const d=a.datasets.find(d=>d.records_per_area===volume); for(const area of ['clients','services','service_drafts','billing_drafts'])for(const page of [25,100]){ const matches=d?.cases.filter(c=>c.area===area&&c.state==='all'&&c.page_size===page)||[]; if(matches.length!==1){missing.push({volume,area,page});continue;} const c=matches[0]; for(const v of variants){ const samples=c.variants[v]; if(!samples?.length||!c.summary[v])missing.push({volume,area,page,variant:v}); for(const s of samples||[])if(!['ok','case_budget_reached'].includes(s.status))throw Error('Unexpected measurement outcome'); if(!c.summary[v].censored&&samples.length!==3)throw Error('Incomplete uncensored case'); } if(!c.successful_responses_identical)throw Error('Response equivalence missing'); coverage.push({records_per_area:volume,area,page_size:page,before:c.summary.baseline,after_joint_read:c.summary.batch,after_joint_read_with_indexes:c.summary.indexed_batch}); } } for(const d of a.datasets)for(const c of d.cases)for(const v of variants)for(const s of c.variants[v]){ if(s.status==='ok')complete++;else if(s.status==='case_budget_reached')limited++;else throw Error('Unclassified sample'); } if(missing.length||coverage.length!==24||complete!==258||limited!==13)throw Error('Coverage gap: '+JSON.stringify({missing,complete,limited})); const summary={date:'2026-11-02',joint_page_read_implemented:true,source_sha256:http.source_sha256,controller_sha256:http.controller_sha256, method:{new_database_connections:0,new_measurements:0,valid_proofs_reused:true,reason:'All 24 required area/volume/page combinations have measured A/B/C outcomes, including explicitly bounded baseline attempts; no dimension is untested.', historical_batch_before_projection_sha256:a.optimized_sha256,current_projection_all_three_volume_matrix_measured:false, current_projection_scope:'Separate 10000-record-per-area, 100-line profiles; do not present historical B as current projected-code measurements.',memory_unit:'bytes',memory_metric:'incremental_php_used_bytes; peak_php_used_bytes also retained',latency_metric:'median_ms only for complete samples'}, coverage,missing_combinations:missing,additional_filter_cases:9,complete_measured_requests:complete,bounded_baseline_attempts:limited, current_projection:projection.experiment,concurrency:{test:concurrent.test,matrix_reads:concurrent.matrix_complete_requests,mixed_reads:concurrent.mixed_read_complete_requests}, release:release.test,http:http.tests,validated_existing_proofs:checked, preservation:{existing_proofs_unchanged:true,protected_six_records_untouched:true,blocked_cache_untouched:true,destination_connected:false,application_code_changed:false, indexes_created:false,rights_changed:false,purchasing_activated:false,publication:false,checkpoint:false},visual_review_pending:true,deployment_capacity_validated:false}; fs.writeFileSync(prefix+'consolidation-summary-20261102.json',JSON.stringify(summary,null,2)+'\n'); console.log(JSON.stringify({required_combinations:coverage.length,missing:missing.length,successful_requests:complete,bounded_attempts:limited,new_measurements:0,prior_hashes_verified:checked.length,current_source_verified:true},null,2));