from pathlib import Path
import hashlib,shutil
root=Path('/home/lighthouse/esp32-dev/.cache/speech-playback-diagnostics-20261006')
# The configured SDKCONFIG path is recorded by CMake; do not guess cache keys.
cache=(root/'firmware/build/CMakeCache.txt').read_text()
line=next(x for x in cache.splitlines() if x.startswith('SDKCONFIG:'))
p=Path(line.split('=',1)[1]);assert p.is_relative_to(root/'.cache/sdkconfig')
backup=root/'.cache/speech-diagnostics/sdkconfig-before-sack.private';assert not backup.exists()
shutil.copyfile(p,backup);backup.chmod(0o600)
s=p.read_text();old='# CONFIG_LWIP_TCP_SACK_OUT is not set';assert s.count(old)==1
p.write_text(s.replace(old,'CONFIG_LWIP_TCP_SACK_OUT=y',1))
print('Only CONFIG_LWIP_TCP_SACK_OUT changed; baseline private SDKCONFIG preserved without printing')
