import os, shutil, json
from pathlib import Path
base = Path('.spt/preserved/deployah-v069-release-20260911')
audit = json.loads((base/'pool-inbound-audit.json').read_text())
assert not audit['inbound_links'] and not audit['errors']
pool = Path('C:/actions-runner/_work/spt-bs-core/spt-bs-core/target')
debug = pool/'debug'
assert not os.path.isjunction(pool) and not pool.is_symlink()
assert not os.path.isjunction(debug) and not debug.is_symlink()
assert 'lane' not in json.loads((pool/'POOL-OWNER.json').read_text())
size = sum(p.stat().st_size for p in debug.rglob('*') if p.is_file())
before = shutil.disk_usage('C:/').free
print(json.dumps({'debug_bytes':size,'free_before':before}), flush=True)
shutil.rmtree(debug)
after = shutil.disk_usage('C:/').free
result = {'deleted':str(debug),'debug_bytes':size,'free_before':before,'free_after':after,'reclaimed_bytes':after-before,'above_floor':after>32*1024**3,'debug_absent':not debug.exists(),'checkout_preserved':(pool.parent/'Cargo.toml').exists(),'release_exists':(pool/'release').exists()}
(base/'reap-result.json').write_text(json.dumps(result,indent=2))
print(json.dumps(result),flush=True)
assert result['above_floor'] and result['debug_absent'] and result['checkout_preserved']
