<?php
declare(strict_types=1);
$main='/workspace/zhct/zhctproject/ai_api';$sources=[];foreach(['B','C'] as $lane){$e=json_decode(file_get_contents(__DIR__.'/evidence-'.$lane.'.json'),true);foreach($e['boundary']['candidate_v2']['reflection'] as $f=>$v){if(hash_file('sha256',$main.'/'.$f)!==$v['sha256']||!$v['actual_private_path'])throw new RuntimeException('Actual private/main source differs '.$f);$sources[$f]=$v['sha256'];}$r=json_decode(file_get_contents(__DIR__.'/resource-cleanup-'.$lane.'.json'),true);if($r['business_DML']!==0||$r['business_cache_files']!==0||!$r['tokens_cache_reclaimed'])throw new RuntimeException('Resources not reclaimed');}
$files=[];foreach(new DirectoryIterator(__DIR__) as $f)if($f->isFile()&&!in_array($f->getFilename(),['manifest.json','MANIFEST.sha256'],true)){$name=$f->getFilename();$files[$name]=hash_file('sha256',$f->getPathname());if(strpos($name,'.apifox-cli.json')!==false){$c=json_decode(file_get_contents($f->getPathname()),true);foreach($c['item'][0]['item'] as $i){if(strpos($i['request']['url'],'staff_id={{staff_id}}')===false)throw new RuntimeException('Natural ID leaked');foreach($i['request']['header'] as $h)if($h['key']==='Access-Token'&&$h['value']!=='{{terminal_token}}')throw new RuntimeException('Token leaked');}}}ksort($files);$m=['task'=>'ZHCTPROMPT-20260928-SMART-CANTEEN-DUAL-DB-COMPAT-PLAN','module'=>'terminal Analysis six GETs','source_revision'=>'bb530e9b78894faa0f83d0d92416a152a468b1c2','source_status'=>'Root writer applied final service candidate; subagent did not write main','final_actual_private_and_main_sha256'=>$sources,'files'=>$files,'private_runtime'=>['B'=>'Docker /tmp/cdx-ai-terminal-analysis-20261010.IyWZ4Y','C'=>'/tmp/cdx-ai-terminal-analysis-20261010.VBsn6n'],'credential_natural_data_policy'=>'Raw response/source rows only 0600 private; control carries type/hash/counts','next_scope'=>'Separate incremental meal.Meal/infos report, same task-level worker/master ownership'];file_put_contents(__DIR__.'/manifest.json',json_encode($m,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));$lines=[];foreach($files as $name=>$sha)$lines[]=$sha.'  '.$name;file_put_contents(__DIR__.'/MANIFEST.sha256',implode("\n",$lines)."\n");echo json_encode(['files'=>count($files),'source_SHA_verified'=>count($sources),'credential_and_natural_ID_free_collections'=>true]),"\n";
