from pathlib import Path
import shutil
root=Path('/home/lighthouse/esp32-dev/.cache/speech-playback-diagnostics-20261006')
line=next(x for x in (root/'firmware/build/CMakeCache.txt').read_text().splitlines() if x.startswith('SDKCONFIG:'))
p=Path(line.split('=',1)[1]);assert p.is_relative_to(root/'.cache/sdkconfig')
s=p.read_text();assert 'CONFIG_LWIP_TCP_SACK_OUT=y' in s
backup=root/'.cache/speech-diagnostics/sdkconfig-sack4.private';assert not backup.exists();shutil.copyfile(p,backup);backup.chmod(0o600)
old='CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4';assert s.count(old)==1;p.write_text(s.replace(old,'CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=12',1))
print('Compared with SACK4, only out-of-order pbuf limit changed from 4 to 12')
