<?php
declare(strict_types=1);require __DIR__.'/common.php';$model='app/store/model/nutrition/NutritionLack.php';$old='8ea785ca5c8717185284e582f253f53fc713b955a4847b150a9c547b8f782d14';$new='a81a7a4eff91aec6745517a26a8794f8ccda4edf633c993406d5c557525d6afd';$check(hash_file('sha256',__DIR__.'/model-final.php')===$new,'Root actual approved model delta');$check(hash_file('sha256',$root.'/'.$model)===$old,'Only upgrade original source once');$snapshot=json_decode(file_get_contents(dirname(__DIR__).'/source-frozen-sha.json'),true);$check(count($snapshot['files'])===6168,'Original6168 files');foreach($snapshot['files'] as $name=>$sha)$check(hash_file('sha256',$root.'/'.$name)===$sha,'All original source before delta '.$name);$original=$prior.'/source-original/'.$model;$check(is_file($original)&&hash_file('sha256',$original)===$old,'Private original Model backup preserved');$check(copy(__DIR__.'/model-final.php',$root.'/'.$model),'Copy sole authorized source delta');$snapshot['files'][$model]=$new;foreach($snapshot['files'] as $name=>$sha)$check(hash_file('sha256',$root.'/'.$name)===$sha,'Final only one file delta '.$name);$snapshot['stage']='final';$snapshot['original_model_sha256']=$old;$snapshot['final_model_sha256']=$new;$json=json_encode($snapshot,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);$check(!file_exists(__DIR__.'/source-final-sha.json'),'Final pin once');file_put_contents(__DIR__.'/source-final-sha.json',$json);chmod(__DIR__.'/source-final-sha.json',0600);$persist('upgrade.json',['lane'=>$lane,'source_files'=>6168,'unchanged_files'=>6167,'sole_changed_path'=>$model,'old_sha256'=>$old,'new_sha256'=>$new,'HTTP'=>0,'DML'=>0,'DDL'=>0]);echo json_encode(['lane'=>$lane,'final_source_files'=>6168,'unchanged_files'=>6167,'model_sha256'=>$new,'HTTP'=>0,'DML'=>0,'DDL'=>0]),"\n";
