42,'security-result.json'=>20,'context-result.json'=>10,'authority-result.json'=>6]as$file=>$count){ $r=json_decode(file_get_contents($proofRoot.'/'.$file),true);if(!($r['passed']??false)||count($r['checks'])!==$count)throw new LogicException('Incomplete proof'); $results[$file]=['sha256'=>hash_file('sha256',$proofRoot.'/'.$file),'checks'=>$r['checks']];$total+=$count; } $snapshot=function($db){$out=[];foreach($db->select("SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename")as$row){$t=$row->tablename;if(!preg_match('/^[a-z_][a-z0-9_]*$/D',$t))throw new LogicException('Table');$out[$t]=(array)$db->selectOne('SELECT count(*) rows, md5(coalesce(string_agg(row_to_json(t)::text, chr(10) ORDER BY row_to_json(t)::text),\'\')) fingerprint FROM "'.$t.'" t');}$out['sequences']=$db->select("SELECT sequencename,last_value FROM pg_sequences WHERE schemaname='public' ORDER BY sequencename");return hash('sha256',json_encode($out,JSON_THROW_ON_ERROR));}; $selected=json_decode(file_get_contents($run['root'].'/private/receipt-composition-cc50a276c10c/state.json'),true); config(['database.connections.sgc_protected_host'=>array_replace(config('database.connections.pgsql'),['host'=>'127.0.0.1','port'=>55439,'database'=>$selected['env']['DB_DATABASE'],'username'=>$selected['env']['DB_USERNAME'],'password'=>$selected['env']['DB_PASSWORD'],'url'=>null]),'database.connections.sgc_protected_native'=>$selected['nativeConnection']]); $base=json_decode(file_get_contents($proofRoot.'/result.json'),true); if($base['protected_8085_fingerprints']!==[$snapshot(DB::connection('sgc_protected_host')),$snapshot(DB::connection('sgc_protected_native'))])throw new RuntimeException('Protected8085 changed'); $prior=json_decode(file_get_contents($repo.'/docs/proofs/purchasing-completion-final-20261104-r2.json'),true); foreach($prior['sources']as$source)if(hash_file('sha256',$selected['app'].'/'.$source['file'])!==$source['sha256'])throw new RuntimeException('Protected8085 code changed'); $unchanged=[];foreach(['app/Modules/Purchasing/InvoiceController.php','app/Modules/Purchasing/ReceiptRuntime.php','packages/payables/src/Payables.php']as$file){$pin=hash_file('sha256',$selected['app'].'/'.$file);if($pin!==hash_file('sha256',$repo.'/'.$file))throw new RuntimeException('Business authority changed: '.$file);$unchanged[]=['file'=>$file,'sha256'=>$pin];} $assoc=json_decode(file_get_contents($repo.'/docs/proofs/module-association-consolidation-summary-20261102.json'),true); if(hash_file('sha256',$repo.'/app/Modules/Identity/Services/ModuleAssociationReview.php')!==$assoc['source_sha256'])throw new RuntimeException('Protected association service changed'); $oldPhysical=json_decode(file_get_contents($s['root'].'/invoice-result.json'),true); $fixture=json_decode(file_get_contents($proofRoot.'/source-fixture.json'),true); $physical=hash('sha256',json_encode([$native->table('goods_receipts')->where('id','<>',$fixture['receipt'])->orderBy('id')->get(),$native->table('goods_receipt_items')->where('goods_receipt_id','<>',$fixture['receipt'])->orderBy('id')->get(),$native->table('stock_movements')->orderBy('id')->get()])); if($physical!==$oldPhysical['physical_fingerprint']||(int)$native->table('budget_consumptions')->sum('amount_minor')!==$oldPhysical['consumed_minor']||$native->table('external_payments')->count()!==0)throw new RuntimeException('Prior financial/physical proof changed'); $files=['bootstrap/app.php','routes/sgc.php','config/sgc_invoice.php','app/Shared/Context/ModuleNavigation.php','app/Http/Middleware/AuthenticateSgcInvoice.php','app/Http/Requests/Sgc/StoreInvoiceRequest.php','app/Http/Controllers/Api/V1/SgcInvoiceIngressController.php','app/Modules/Purchasing/SgcInvoiceIngress.php','scripts/sgc-invoice-proof-bootstrap.php','scripts/sgc-invoice-proof.php','scripts/sgc-invoice-security-proof.php','scripts/sgc-invoice-context-proof.php','scripts/sgc-invoice-authority-proof.php','scripts/sgc-invoice-check.mjs','scripts/summarize-sgc-invoice.php','tests/payloads/invoice_test.json']; $defaults=require $repo.'/config/sgc_invoice.php';if($defaults!==['enabled'=>false,'principals'=>[]])throw new RuntimeException('Source must remain disabled'); $proof=['date'=>'2026-11-10','passed'=>true,'checks'=>$total,'tests'=>$results,'transport'=>'Laravel HTTP kernel, actual PostgreSQL and independent PHP workers; no TCP server', 'routes'=>['POST /api/v1/integration/sgc/invoices','GET /api/v1/integration/sgc/invoices/orders/{order}'], 'result'=>['new_pending_invoices'=>$base['new_pending_invoices'],'concurrent_statuses'=>$base['concurrent_statuses'],'lock_statuses'=>[503,200],'invoice_audit_atomicity_proved'=>true,'workflow'=>'original pending invoice writer','auto_financial_validation'=>false], 'isolation'=>['existing_regression_book'=>'da77bb730751','source_fixture'=>'SQL fixture only; not executed request/award/receipt/stock workflows','protected_8085_hashes'=>$base['protected_8085_fingerprints'],'protected_8085_code_unchanged'=>true,'prior_receipts_and_movements_sha256'=>$physical,'prior_consumed_minor'=>10000,'external_payments'=>0,'six_protected_records_changed'=>false,'cache_cleared'=>false,'new_database'=>false,'new_role'=>false,'new_server'=>false,'new_demo'=>false,'new_real_grants'=>false], 'disabled_configuration'=>$defaults,'publication'=>false,'checkpoint'=>false,'business_authority_unchanged'=>$unchanged, 'sources'=>array_map(fn($file)=>['file'=>$file,'sha256'=>hash_file('sha256',$repo.'/'.$file)],$files), 'report'=>'docs/SGC_INVOICE_ENDPOINT.md','limitations'=>['QA adapter only; no real activation/deployment.','Kernel requests are not network/TLS/visual or sustained-load tests.','Initial72 checks reused; last6 exercise the strengthened native-operator recovery guard without repeating writes.','Synthetic bearer tokens, encrypted previews and private logs are excluded from this proof.','Source preparation adds SQL fixtures to the existing regression book; previous proofs and rows are preserved.']]; file_put_contents($out,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_THROW_ON_ERROR).PHP_EOL);echo json_encode(['passed'=>true,'checks'=>$total,'proof'=>'docs/proofs/sgc-invoice-endpoint-20261110.json']).PHP_EOL;