<?php
$protected=static function(array $before,array $after,string $uuid){$strip=static function(array $s)use($uuid){foreach($s['nutrition']as &$r)if($r['uuid']===$uuid)unset($r['use_weight']);unset($r);return $s;};if($strip($before)!==$strip($after))throw new RuntimeException('Full protected lease drift');return true;};
$physical=static function(string $uuid)use($db,$lane){$sql=$lane==='B'?'SELECT use_weight,use_weight+0e0 AS computed_weight FROM ydy_nutrition WHERE uuid=?':'SELECT use_weight,CAST(use_weight AS DOUBLE) AS computed_weight FROM ydy_nutrition WHERE uuid=?';NFObserverBudget::take();$s=$db->prepare($sql);$s->bindValue(1,$uuid,PDO::PARAM_STR);$s->execute();$rows=$s->fetchAll(PDO::FETCH_ASSOC);if(count($rows)!==1)throw new RuntimeException('Exact physical one row');$record=['sql'=>$s->queryString,'binds'=>[['value'=>$uuid,'type'=>PDO::PARAM_STR]],'rowCount'=>$s->rowCount(),'fields'=>[],'metadata'=>[],'errorInfo'=>$s->errorInfo()];foreach(array_change_key_case($rows[0],CASE_LOWER)as $f=>$v)$record['fields'][$f]=['value'=>$v,'php_type'=>gettype($v),'bits64'=>is_float($v)?bin2hex(pack('d',$v)):null];for($i=0;$i<2;$i++){try{$m=$s->getColumnMeta($i);$record['metadata'][]=['supported'=>$m!==false,'value'=>$m];}catch(Throwable $e){$record['metadata'][]=['supported'=>false,'error'=>['class'=>get_class($e),'message'=>$e->getMessage()]];}}return $record;};
$included=static function(){$r=[];foreach(get_included_files()as $f)$r[]=['file'=>$f,'sha256'=>is_file($f)?hash_file('sha256',$f):null];return $r;};

