<?php
require __DIR__.'/common.php';if(is_file(__DIR__.'/private/before.json'))throw new RuntimeException('No lease replay');$s=$source();$prior=json_decode(file_get_contents(__DIR__.'/expected-original-after-'.$lane.'.json'),true);$a=$s;$b=$prior;unset($a['active_count'],$a['config_lease'],$b['active_count']);if($a!==$b)throw new RuntimeException('Exact original product/actor must remain unchanged');$p=$s['nutrition'][0];$expectedActor=$lane==='B'?['id'=>97260,'uuid'=>'CDXUSER-A94A908CCF322DC72E566A2DC9','account'=>'CDXPAY72BEB125']:['id'=>2791,'uuid'=>'2852F2D7-9B88-45F6-A53D-495744CA1CAE','account'=>'CDXDMENU10C3EED1F43'];foreach($expectedActor as $k=>$v)if($s['actor'][0][$k]!==$v)throw new RuntimeException('Exact original actor');if($s['actor'][0]['type']!==0||$s['match_count'][0]['n']!==1||$p['is_own']!==1||$p['status']!==1||$p['is_del']!==1||round((float)$p['use_weight'],3)!==123.457)throw new RuntimeException('Single stable plain fixture lease');
$meta=[];foreach(['nutrition','nutrition_set','nutrition_category','nutrition_time','user','config']as $table)$meta[$table]=$lane==='B'?$q('SELECT COLUMN_NAME,COLUMN_TYPE,IS_NULLABLE,COLUMN_DEFAULT,EXTRA FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=? ORDER BY ORDINAL_POSITION',['ydy_'.$table]):$q('SELECT COLUMN_NAME,DATA_TYPE,DATA_LENGTH,DATA_PRECISION,DATA_SCALE,NULLABLE,DATA_DEFAULT FROM USER_TAB_COLUMNS WHERE TABLE_NAME=? ORDER BY COLUMN_ID',['YDY_'.strtoupper($table)]);
$save('before.json',$s);$save('lease-oracle.json',$GLOBALS['NR_ORACLE']);$save('metadata.json',$meta);$save('lease.json',['HTTP'=>0,'DML'=>0,'DDL'=>0,'matching_rows'=>1,'actor_original_chain'=>true]);echo json_encode(['lane'=>$lane,'HTTP'=>0,'DML'=>0,'matching_rows'=>1]),"\n";
