<?php
// Filesystem-only mechanical projection of sealed evidence. No database/Auth/HTTP.
function apj($v){$s=json_encode($v,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_PRESERVE_ZERO_FRACTION);if($s===false)throw new RuntimeException('JSON');return $s;}
$dir='/tmp/cdx-prepay-code-scan-fresh-package-20261011';if(file_exists($dir)||!mkdir($dir,0700))throw new RuntimeException('Own private package collision');$public=[];
foreach(['B','C']as $lane){$core='/tmp/cdx-ai-core-scan-pay-20261011/private-'.$lane.'-final/';$latest='/tmp/cdx-ai-core-direct002-20261011/private-'.$lane.'-final/';$prepared=json_decode(file_get_contents($core.'prepared.json'),true);$protection=json_decode(file_get_contents($core.'protection-'.$lane.'.json'),true);$persist=json_decode(file_get_contents($latest.'persistence-final.json'),true);$preflight=json_decode(file_get_contents($core.'preflight-'.$lane.'.json'),true);$money=json_decode(file_get_contents($latest.'physical-money-final.json'),true);
 $baseline=['lane'=>$lane,'ids'=>$prepared['ids'],'old13'=>$persist['old_fullrows'],'own16'=>$persist['own_fullrows'],'money'=>$money['whole_declared_DECIMAL_columns'],'source_hashes'=>['latest_persistence'=>hash_file('sha256',$latest.'persistence-final.json'),'old13'=>hash_file('sha256',$core.'protection-'.$lane.'.json'),'prepared'=>hash_file('sha256',$core.'prepared.json')]];
 if($lane==='C'){$receipt='/Users/wiscourper/Documents/workspace/local/dm8-prepay-formal-root-evidence-20261011.6Sibqq/events.jsonl';if(hash_file('sha256',$receipt)!=='7235505367496cf281c30ea7c2fb570b850a31ee747d2d8c0dcd16b645337aca')throw new RuntimeException('Root formal receipt SHA');$h=fopen($receipt,'r');$post=[];while(($line=fgets($h))!==false){$e=json_decode($line,true);if(($e['event']??'')==='original-read-result'&&$e['statement']['phase']==='after_trigger_stable')$post[$e['statement']['label']]=$e['rows'];}fclose($h);$native=[];foreach($post['rows_before']as $row){$n=[];foreach($post['columns']as $c)$n[strtolower($c['column_name'])]=$row[strtolower($c['column_name'])];$native[(string)$row['id']]=$n;}$baseline['own16']['STORE_P1']=[$native[(string)$prepared['ids']['STORE_P1']]];foreach($baseline['old13']['ZHCT.prepay_order']as &$row){if(!isset($native[(string)$row['id']]))throw new RuntimeException('Old protected prepay absent Rootreceipt');$row=$native[(string)$row['id']];}unset($row);$baseline['formal_prepay_metadata']=$post;$baseline['source_hashes']['formal_receipt']='7235505367496cf281c30ea7c2fb570b850a31ee747d2d8c0dcd16b645337aca';}
 $file=$dir.'/baseline-'.$lane.'.json';$h=fopen($file,'x');chmod($file,0600);fwrite($h,apj($baseline)."\n");fclose($h);
 $public[$lane]=['ids'=>$prepared['ids'],'old13_queries'=>$protection['native_SELECT_events'],'own_order_ids'=>array_column($persist['own_fullrows']['meal_order'],'id'),'staff_uuid'=>$persist['own_fullrows']['STORE_S1'][0]['uuid'],'baseline_sha256'=>hash_file('sha256',$file),'baseline_bytes'=>filesize($file),'schema_decimal_fields'=>[]];foreach($public[$lane]['old13_queries']as &$q){unset($q['rows'],$q['full_rows_sha256'],$q['rowCount'],$q['execute_success'],$q['operation']);}unset($q);
 foreach([['AI','user'],['AI','account_settlement'],['AI','user_balance_log'],['ZHCT','meal_order']]as $pair){$fields=[];foreach($preflight['schema'][$pair[0]][$pair[1]]['columns']as $c)if(strtolower($c['data_type'])==='decimal')$fields[]=strtolower($c['column_name']);$public[$lane]['schema_decimal_fields'][$pair[0].'.'.$pair[1]]=$fields;}
}
echo apj($public);
