import hashlib,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,rc=0):
    result=subprocess.run(command,capture_output=True,text=True)
    assert result.returncode==rc,(command,result.returncode,result.stderr)
    return result.stdout
result=run(['docker','exec','zhctapp_v2_0','/usr/local/php7.3/bin/php','/workspace/zhct/zhctproject/store/tests/Nutrition/DateResponseContract.check.php'])
(private/'root-main-tdd.json').write_text(result)
commands={
'B':['docker','exec','zhctapp_v2_0','/usr/local/php7.3/bin/php','/tmp/cdx-nutrition-read5-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-read5-C-20261011/cleanup.php C']}
for lane,command in commands.items():
    target=private/(lane+'-cleanup.json');assert not target.exists(),'Do not replay cleanup'
    result=run(command);assert json.loads(result)['original_service_alive'] is True
    target.write_text(result);os.chmod(target,0o600)
print('Root TDD148 and both exact owned runtime cleanup receipts saved')
