import json,subprocess,os
from pathlib import Path

slice_dir=Path(__file__).resolve().parent;private=slice_dir/'private-evidence'
assert not (private/'final-manifest.json').exists(),'Already sealed'
assert not any((private/(lane+'-cleanup.json')).exists() for lane in ('B','C')),'Cleanup cannot replay'
def run(command):
    result=subprocess.run(command,capture_output=True,text=True);assert result.returncode==0,(result.returncode,result.stderr);return result.stdout
for label,test in [('root-main-product132','ProductDateResponseContract.check.php'),('root-main-prior148','DateResponseContract.check.php')]:
    result=run(['docker','exec','zhctapp_v2_0','/usr/local/php7.3/bin/php','/workspace/zhct/zhctproject/store/tests/Nutrition/'+test]);assert json.loads(result)['passed'];(private/(label+'.json')).write_text(result)
commands={'B':['docker','exec','zhctapp_v2_0','/usr/local/php7.3/bin/php','/tmp/cdx-nutrition-product10-B-20261011/cleanup.php','B'],'C':['ssh','-S','/private/tmp/cdx-train-root-20261010.sock','-o','BatchMode=yes','root@121.43.241.161','/www/server/php/73/bin/php /tmp/cdx-nutrition-product10-C-20261011/cleanup.php C']}
for lane,command in commands.items():
    result=run(command);assert json.loads(result)['original_service_alive'];target=private/(lane+'-cleanup.json');target.write_text(result);os.chmod(target,0o600)
print('Root280 tests and two exact owned cleanup receipts saved')
