<?php
declare(strict_types=1);
// Only exact own runtime files, after local archive SHA confirmation. No PDO/SQL.
$r='/tmp/cdx-nfl-C-20261011.lNnsY9';
$expected=[
 'gate.php'=>'e29201e46a5d866b7029f4a94034e672bb8d3684b08cc1b0ca0dece0f00ec8e0',
 'gate.check.php'=>'21a395e5d38c1467eda07bf1381193a3e80dc81d60277f74691e61486ac8d902',
 'runner.php'=>'e4e506d423ee2d3bb18f4aac489d43c79a4cfdc7e5db537d648985482eba80c7',
 'launch-C.php'=>'cb1ca8dcea2a66872f57da7555ba8498c6589387ce0961cb0a13200ed09b80b0',
 'plan.json'=>'b9957993cdfaa2053d4fae87f77e74de58d25331b523576ca166f93fc518c345',
 'private-run-C.jsonl'=>'7560ebc93bc675dd45fd2b8f293c14f18d1c5e661225aa6668ce9a7bbaea136b'];
if(__FILE__!==$r.'/cleanup-runtime.php'||!is_dir($r)||is_link($r)||(fileperms($r)&0777)!==0700)exit(90);
$names=array_values(array_diff(scandir($r),['.','..']));sort($names);$required=array_merge(array_keys($expected),['cleanup-runtime.php']);sort($required);if($names!==$required)exit(91);
foreach($expected as $name=>$sha)if(!is_file($r.'/'.$name)||is_link($r.'/'.$name)||hash_file('sha256',$r.'/'.$name)!==$sha)exit(92);
$cmd=file_get_contents('/proc/112175/cmdline');$parentOk=is_string($cmd)&&strpos(str_replace(chr(0),' ',$cmd),'/tmp/zhct-dm-poc-20260928.fcpiiN/store')!==false;unset($cmd);if(!$parentOk)exit(93);
$selfSha=hash_file('sha256',__FILE__);$removed=[];
foreach(array_keys($expected)as $name){if(!unlink($r.'/'.$name))exit(94);$removed[]=$name;}
if(!unlink(__FILE__))exit(95);$removed[]='cleanup-runtime.php';if(!rmdir($r))exit(96);
echo json_encode(['status'=>'OWN_RUNTIME_CLEANUP_COMPLETE','path'=>$r,'removed_files'=>$removed,'verified_sha256'=>$expected,'cleanup_script_sha256'=>$selfSha,'parent112175_identity_alive'=>true,'directory_absent'=>!file_exists($r),'SQL'=>0,'configs_env_keys_source_bundles_not_copied'=>true]),"\n";
