from pathlib import Path import json,os,re,subprocess,hashlib,datetime,struct B={'observed_completed_at': '2026-10-20T20:36:12.994964+00:00', 'source_revision': 'ffa19e381de7151708ad339846660ec19d16ebda', 'profile': 'k230-mainline-drm-shell-landscape-hdmi', 'builds': [{'command': 'nix build git+file://?rev=#handheld-settings --max-jobs 4 --cores 8', 'exit_code': 0, 'output': '/nix/store/kdc5bmnqf6n5px5nfsv0iz8l02d1azah-k230-settings'}, {'command': 'nix build git+file://?rev=#nixosConfigurations.k230-mainline-drm-shell-landscape-hdmi.config.system.build.toplevel --max-jobs 4 --cores 8', 'exit_code': 0, 'output': '/nix/store/p501mchy0dq9lyjnaxwkx5s2pdm4i2yj-nixos-system-nixos-26.11.20260919.20b1ddd'}], 'build_lock': '/tmp/k230-nix-build.lock; each build held flock exclusively and released on exit', 'native': {'path': '/nix/store/fm6zs80m11nc122z0djwaycz0zrhnbij-k230-settings-status-riscv64-unknown-linux-gnu-0.1.0/bin/k230-settings-status', 'bytes': 18096, 'sha256': 'c262a1f1aaff1cb3a5b353f3880f1dfbe197d8fbe40bbb8510261a19a9283cd0'}, 'wrapper_sha256': '9a38a0562fd57707fe2430d1e72598b22f768cc07824785a9cb9f0c49754f4c7', 'ui_wrapper': '/nix/store/52ad5p0y2g0ynskm9bb7c0qbw4glh144-k230-shell-rust/bin/k230-shell-rust', 'ui_wrapper_sha256': 'bb81738e03e7ba670ce8a088c26745f0d222cf29767acf7d05166754f08b26df', 'kernel': {'path': '/nix/store/21lz5c6pkk329c0xcac9bzlx40dplrlk-linux-riscv64-unknown-linux-gnu-7.3.0-rc5/Image', 'same_store_path_as_accepted_system': True, 'sha256': 'd6b2153d97ac8382b5329c64397b8b46435e6a423b16796f8c37e052d4bcd642'}, 'new_store_paths': ['/nix/store/1l78djhwlirzh2jg0kjqynjvq206sddm-unit-shell.service', '/nix/store/52ad5p0y2g0ynskm9bb7c0qbw4glh144-k230-shell-rust', '/nix/store/7khi8238q2qbx1wsyw6ivvn7nhc1sa4z-k230-sway.conf', '/nix/store/ayhclb0kgl2pdmla5whdxmr69h3bfm1h-unit-dbus-broker.service', '/nix/store/fm6zs80m11nc122z0djwaycz0zrhnbij-k230-settings-status-riscv64-unknown-linux-gnu-0.1.0', '/nix/store/k67p4pqg9n8vqk9kw3qf0n2xlp3dh69g-unit-shell-ui.service', '/nix/store/kdc5bmnqf6n5px5nfsv0iz8l02d1azah-k230-settings', '/nix/store/l4hax3x9apgj6fp4ys9qfy2lmxqdb26r-X-Restart-Triggers-dbus-broker', '/nix/store/lgdc6zb7la31hn0i09idr1402hw0b9kj-dbus-1', '/nix/store/lp1qx9xzk7z7rnyd54aw6sys2rwzclcr-etc', '/nix/store/m2b4zpd5dvb7brl0xsvcr7q75sp2jcw6-system-path', '/nix/store/mb7q0rscfz0f7g8c3ihyqkdvm448m7a3-system-units', '/nix/store/p501mchy0dq9lyjnaxwkx5s2pdm4i2yj-nixos-system-nixos-26.11.20260919.20b1ddd', '/nix/store/vf6bwd1sh4hvpf1cpk7f0ipyyzawklvv-unit-dbus-broker.service', '/nix/store/zpcsahs0maj2j4rpvk7z4dj0rdkk8dwy-user-units'], 'incremental_nar_bytes_vs_accepted_system': 4144432, 'limits': 'Cross-build and closure identities only; no copy/activation/performance/physical/persistence proof.', 'boot_bundle': '/nix/store/pa46qfg8v8pdgdgmk7lai218wmh4dzh9-k230-coherent-shell-boot-files', 'boot_bundle_files': {'initrd.uimg': {'bytes': 27328407, 'sha256': '7d983aeffd4e47d2e36f825a731b485d55f05534a5dd28f036244d79c16f197c'}, 'Image': {'bytes': 42752512, 'sha256': 'd6b2153d97ac8382b5329c64397b8b46435e6a423b16796f8c37e052d4bcd642'}, 'k230-tdisplay.dtb': {'bytes': 19048, 'sha256': 'ad61b8a70acba495b77761a6e73e935c4cd8ccd2a7ca6eb3da7fca6c256a18df'}, 'bootargs.txt': {'bytes': 198, 'sha256': '38a90761c55914c426828c41d1c8b1cb636d19cda6893859d43afbe64c0fefc4'}}, 'boot_bundle_build': {'attribute': 'kernelMainlineDrmShellLandscapeHdmiBootFiles', 'exit_code': 0, 'completed_observed_at': '2026-10-20T20:38:07.799399+00:00'}} EXPECTED={'systems': {'/run/current-system': '/nix/store/hpmzja32mncizz7s49ylr8pj9cy5npvg-nixos-system-nixos-26.11.20260919.20b1ddd', '/run/booted-system': '/nix/store/hpmzja32mncizz7s49ylr8pj9cy5npvg-nixos-system-nixos-26.11.20260919.20b1ddd', '/nix/var/nix/profiles/system': '/nix/store/hpmzja32mncizz7s49ylr8pj9cy5npvg-nixos-system-nixos-26.11.20260919.20b1ddd'}, 'boot_id': '69e90426-5ead-4ebb-82d5-2a592168e34d', 'boot_files': {'Image': 'd6b2153d97ac8382b5329c64397b8b46435e6a423b16796f8c37e052d4bcd642', 'initrd.uimg': '7d983aeffd4e47d2e36f825a731b485d55f05534a5dd28f036244d79c16f197c', 'k230-tdisplay.dtb': '71846b14ec47456fe9bec713ee850c97e1d8c1563afa9ffe21ac87da196ed581', 'bootargs.txt': '09c0214ca1b36924ad5a24662e1f55efd137a8eff2e7d1052127d318eb3ca6b7', 'fw_jump_add_uboot_head.bin': '9627edbeea9b115d7040beea27cc61b23b6aca61cd502fd7760d7ee179f42c99'}, 'tracing': {'current_tracer': '64aec5a7fa151222572a241383c857738318e63cca7ee771952c95a31d92a19d', 'tracing_on': '4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865', 'trace_clock': '925ca315bd3de6ef99e08c002e320406936ae2da2f2c0afd8da1e87f7980a253', 'events/enable': '9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa', 'set_event_pid': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'set_ftrace_pid': 'cdf4d2acfdcd5cd2556f83eeb52ee253ea6afbaa941c760f77dcfae3c925cb78', 'set_ftrace_filter': '5c83074a334aa00236037c3c0621b592cf3c740b5f5977f6ee95a308c5c8281e', 'set_graph_function': '5c83074a334aa00236037c3c0621b592cf3c740b5f5977f6ee95a308c5c8281e', 'trace_options': 'a01cdd327a047d28b4241491a330220fa96feba5a60309dee36ca7e3bbd9204a'}, 'backup': {'Image': 'd0cd1b14f4c32b7208500cf7710a83e2804a12111043c7fb95e4b6fe01469940', 'initrd.uimg': '1146f947158f07c625edef03b7467212213789c2c29644148afcbd554a4b17d7', 'k230-tdisplay.dtb': 'da9f9e697d00e3c3e8e863b7633d4d2004751249df30280372e817cf5713aecc', 'bootargs.txt': 'e211e351cfccfd4275dcf77ed79be088dcc025904c3209264586dad492c1fd88', 'fw_jump_add_uboot_head.bin': '9627edbeea9b115d7040beea27cc61b23b6aca61cd502fd7760d7ee179f42c99'}, 'expected_backup': {'Image': 'd0cd1b14f4c32b7208500cf7710a83e2804a12111043c7fb95e4b6fe01469940', 'initrd.uimg': '1146f947158f07c625edef03b7467212213789c2c29644148afcbd554a4b17d7', 'k230-tdisplay.dtb': 'da9f9e697d00e3c3e8e863b7633d4d2004751249df30280372e817cf5713aecc', 'bootargs.txt': 'e211e351cfccfd4275dcf77ed79be088dcc025904c3209264586dad492c1fd88', 'fw_jump_add_uboot_head.bin': '9627edbeea9b115d7040beea27cc61b23b6aca61cd502fd7760d7ee179f42c99'}, 'roots': {'accepted-candidate-root': '/nix/store/hpmzja32mncizz7s49ylr8pj9cy5npvg-nixos-system-nixos-26.11.20260919.20b1ddd', 'rollback-system-root': '/nix/store/j30yag05ic9k68n9dzbzindgf4ardp08-nixos-system-nixos-26.11.20260919.20b1ddd'}, 'kernel_notes_sha256': '1a98ea1e0a6e75f923c0fd53cfcf472f576ddb36de86b89361bfc224a305d9b6'} sha=lambda p:hashlib.file_digest(Path(p).open('rb'),'sha256').hexdigest() assert all(os.path.realpath(p)==s for p,s in EXPECTED['systems'].items()) assert Path('/proc/sys/kernel/random/boot_id').read_text().strip()==EXPECTED['boot_id'] assert sha('/sys/kernel/notes')==EXPECTED['kernel_notes_sha256'] for n,h in EXPECTED['boot_files'].items():assert sha('/boot/'+n)==h for n,h in EXPECTED['tracing'].items():assert sha('/sys/kernel/tracing/'+n)==h assert sha(B['native']['path'])==B['native']['sha256'] newsettings=B['builds'][0]['output']+'/bin/k230-settings';assert sha(newsettings)==B['wrapper_sha256'] assert sha(B['ui_wrapper'])==B['ui_wrapper_sha256'] assert '/nix/store/fj1v8k4sl1v48qx1v7qafzd9c1g3i259-k230-shell-rust-riscv64-unknown-linux-gnu-0.1.0/bin/k230-shell-rust' in Path(B['ui_wrapper']).read_text() new_system=B['builds'][1]['output'];assert os.path.realpath(new_system+'/kernel')==B['kernel']['path'] old_ui=re.search(r'^ExecStart=([^ ]+)',Path('/run/current-system/etc/systemd/system/shell-ui.service').read_text(),re.M)[1] rust=int(subprocess.check_output(['systemctl','show','shell-ui','-p','MainPID','--value'],text=True).strip());env=dict(x.partition(b'=')[::2] for x in Path(f'/proc/{rust}/environ').read_bytes().split(b'\0') if b'=' in x);oldsettings=os.fsdecode(env[b'K230_SETTINGS']) assert sha('/nix/store/qc4fg0nvm8i3lpclnyji2ms68axr0vf3-device_settings.py')=='130bd6a560176f112d9c3a677c76bafa591a40aec97c744cd362d6c5485f4106' assert sha(f'/proc/{rust}/exe')=='32c8c445eb0e9467114880d0084762aa6649e69b1274ba7f87d24e300bee9148' assert not any(x.startswith(b'K230_TRACE_') for x in env) root=Path('/var/lib/k230/shade-status-candidate-root');assert not root.exists() and not root.is_symlink() subprocess.run(['nix-store','--add-root',str(root),'--indirect','--realise',new_system],check=True,stdout=subprocess.DEVNULL) assert os.path.realpath(root)==new_system v={'utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'baseline_ui_wrapper':old_ui,'candidate_ui_wrapper':B['ui_wrapper'],'baseline_settings':oldsettings,'candidate_settings':newsettings,'ui_wrapper_hashes':{p:sha(p) for p in [old_ui,B['ui_wrapper']]},'settings_wrapper_hashes':{p:sha(p) for p in [oldsettings,newsettings]},'sway_sha256':'9464072ac100e77500c7b6113920d2c2ed14e022612eddbc38a037ce9b006670','rust_sha256':sha(f'/proc/{rust}/exe'),'kernel_notes_sha256':EXPECTED['kernel_notes_sha256'],'boot_files':EXPECTED['boot_files'],'tracing':EXPECTED['tracing'],'tracefs_mounted':Path('/sys/kernel/tracing/current_tracer').exists(),'systems':EXPECTED['systems'],'candidate_system':new_system,'candidate_gc_root':str(root),'native':B['native'],'root_available_bytes':os.statvfs('/').f_bavail*os.statvfs('/').f_frsize} assert v['root_available_bytes']>64*1024*1024 Path('/run/pane23-shade-status/identity.json').write_text(json.dumps(v,indent=2)+'\n');print(json.dumps(v,indent=2))