from pathlib import Path import subprocess,json,time,datetime b=Path(__file__).parent;ssh=['ssh','-F',str(Path.home()/'tmp/k230-coordination/ssh_config.private'),'-o','ConnectTimeout=3','k230'];py='/nix/store/v189xydz6qkcd4cbkixcmv91w8hbc560-python3-riscv64-unknown-linux-gnu-3.14.7/bin/python3 -';candidate='/nix/store/hpmzja32mncizz7s49ylr8pj9cy5npvg-nixos-system-nixos-26.11.20260919.20b1ddd';normal='/nix/store/j30yag05ic9k68n9dzbzindgf4ardp08-nixos-system-nixos-26.11.20260919.20b1ddd';old='c17ee483-0191-48ea-986a-9738a274393e';expected='7a61d8cea3e26df94695189b766de3fd66fa6860';now=lambda:datetime.datetime.now(datetime.timezone.utc).isoformat() code="""from pathlib import Path import os,json,struct,hashlib raw=Path('/sys/kernel/notes').read_bytes();i=0;ids=[] while i+12<=len(raw): ns,ds,t=struct.unpack_from('4096 or ds>4096 or i+((ns+3)//4*4)+ds>len(raw):raise ValueError('invalid note bound') name=raw[i:i+ns].rstrip(b'\\0');i+=(ns+3)//4*4;data=raw[i:i+ds];i+=(ds+3)//4*4 if name==b'GNU' and t==3:ids.append(data.hex()) assert len(ids)==1 print(json.dumps({'boot_id':Path('/proc/sys/kernel/random/boot_id').read_text().strip(),'system':os.path.realpath('/run/current-system'),'booted_system':os.path.realpath('/run/booted-system'),'persistent_system':os.path.realpath('/nix/var/nix/profiles/system'),'kernel_build_id':ids[0],'kernel_notes_sha256':hashlib.sha256(raw).hexdigest(),'init_tokens':[s for s in Path('/proc/cmdline').read_text().split() if s.startswith('init=')]})) """ v={'started_at':now(),'status':'WAITING_SSH','expected_build_id':expected,'candidate_system':candidate,'preserved_system':normal,'expected_persistent_system':candidate,'reboot_method':'systemctl reboot; ordinary U-Boot autoboot, no kexec','old_boot_id':old,'attempts':0};out=b/'stable-poll-ordinary-boot-observation.json';deadline=time.monotonic()+240 while time.monotonic()