The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Polish USB startup and complete encrypted installation cleanly (#719)
Deeb1b912b6999a
diff --git a/.github/workflows/os.yml b/.github/workflows/os.ymlindex a50a88f95..fa1500bbd 100644--- a/.github/workflows/os.yml+++ b/.github/workflows/os.yml@@ -95,10 +95,17 @@ jobs:workspaces: tuishared-key: tui-x86_64-unknown-linux-muslcache-bin: false- - name: Build Harness from the exact OS source+ - name: Prepare native build toolsrun: |sudo apt-get update -qq- sudo apt-get install -y musl-tools tmux+ sudo apt-get install -y musl-tools tmux cryptsetup-bin btrfs-progs+ - name: Check encrypted cleanup with real device readers and stalled udev+ run: |+ # Fail early on real cleanup semantics, before compressing an ISO.+ # The fixture owns a temporary file/loop device, never a host disk.+ sudo python3 os/tests/installer-cleanup-native.py --output os/test-results/cleanup-host+ - name: Build Harness from the exact OS source+ run: |make -C os runtime- name: Validate hn session behavior and native terminal lifecyclerun: |@@ -137,6 +144,7 @@ jobs:name: programmer-os-build-diagnosticspath: |.harness/validation/+ os/test-results/cleanup-host/receipt.jsonos/work/profile/profiledef.shos/work/profile/pacman.confos/work/archiso/x86_64/airootfs/var/log/pacman.logdiff --git a/docs/naming-system.md b/docs/naming-system.mdindex 061493ab7..0c0d9f100 100644--- a/docs/naming-system.md+++ b/docs/naming-system.md@@ -103,6 +103,7 @@ configuration where it affects a decision.| Surface | Wording || --- | --- || Boot and unlock branding | **Harness** |+| First-use description | **The operating system built by agents, for agents.** || Disk unlock prompt | **Enter your password** || USB install action | **Install Harness** || Offline USB action | **Install without connecting** |diff --git a/os/INSTALL.md b/os/INSTALL.mdindex e894c8bf3..5513e3c54 100644--- a/os/INSTALL.md+++ b/os/INSTALL.md@@ -1,6 +1,6 @@# Install Harness on a ThinkPad-These instructions are for **0.1.0-preview.9**, using a Mac to prepare the USB.+These instructions are for **0.1.0-preview.10**, using a Mac to prepare the USB.The USB starts a live session. Installation begins only when you choose **Install Harness**in the installer; it erases the entire selected disk.@@ -21,20 +21,20 @@ compute still need testing on the actual hardware.## 2. Download and verify on the Mac-From the [preview 9 release](https://github.com/autonomous-ai/openharness/releases/tag/os-v0.1.0-preview.9),+From the [preview 10 release](https://github.com/autonomous-ai/openharness/releases/tag/os-v0.1.0-preview.10),download both files into the same folder:-- `harness-0.1.0-preview.9-x86_64.iso`-- `harness-0.1.0-preview.9-x86_64.iso.sha256`+- `harness-0.1.0-preview.10-x86_64.iso`+- `harness-0.1.0-preview.10-x86_64.iso.sha256`If they are in Downloads, open Terminal and run:```shcd ~/Downloads-shasum -a 256 -c harness-0.1.0-preview.9-x86_64.iso.sha256+shasum -a 256 -c harness-0.1.0-preview.10-x86_64.iso.sha256```-The result must say `harness-0.1.0-preview.9-x86_64.iso: OK`.+The result must say `harness-0.1.0-preview.10-x86_64.iso: OK`.If it does not, download the files again before flashing.## 3. Flash the USB@@ -174,8 +174,8 @@ install the tools the project needs. Save work under `~/projects`.## 8. Updates-A small **Update ready · Super+u** notice appears when a new hn or CLI release-has downloaded and passed its checks. Press **Super+u**, then Enter to apply it.+Press **Super+u** to see available hn, CLI and system updates. New hn/CLI+releases download in the background; press Enter in Updates to apply a ready runtime.The screen reconnects; your running agents and terminal processes remain.Use **r** in Updates to restore the previous runtime if needed.@@ -184,15 +184,16 @@ They retain a recovery checkpoint and rebuild the boot image. When the screenoffers **Restart now**, save your work and press Enter when ready. Downloads donot restart the computer, and routine updates do not require another USB flash.-Preview 5 through 8 can receive preview 9 through **Super+u**, then **s**.+Preview 5 through 9 can receive preview 10 through **Super+u**, then **s**.It includes the new network page, first-use workspace, lowercase project folders,and the fix preventing older public CLI releases from replacing the bundledOpenCode compatibility code. Running work is preserved; save before restarting.No reinstallation or USB flash is needed for these installed-system changes.-Preview 9 also fixes a transient encrypted-disk cleanup failure in the USB-installer. A computer that already boots successfully needs no reinstallation-for that cleanup fix.+Preview 10 fixes repeated Wi-Fi setup and the final encrypted-device cleanup+timeout. The USB bar is green; installed Harness keeps its normal status bar.+Ctrl+b, then c opens a terminal tab. USB improvements require flashing the new ISO;+an already installed computer can receive the OS changes through Updates.Preview 4 needs the 7.2 MB [preview 7 bootstrap bundle](https://github.com/autonomous-ai/openharness/releases/download/os-v0.1.0-preview.7/harness-update-0.1.0-preview.7-47872670a-x86_64.zip)once. Verify and extract that bundle, open a terminal in its folder, and run:diff --git a/os/README.md b/os/README.mdindex f99f517ac..14a466d94 100644--- a/os/README.md+++ b/os/README.md@@ -11,17 +11,17 @@ audience, not its name.Product names and interface copy follow the [Naming System](../docs/naming-system.md).-**Preview 9:** the USB opens a short network step+**Preview 10:** the USB opens a short network stepor goes straight into bundled OpenCode when already connected. **Install withoutconnecting** opens the same native installer offline. OpenCode starts on the left with two real terminal panes on the right.-The single footer holds the window list on the left and **Make Harness your OS.+The single green USB footer holds the window list on the left and **Make Harness your OS.[ Install Harness ]** on the right. Installed first boot uses the same workspace;-later launches restore existing work. Saved `~/projects` files are copied+later launches restore existing work. The installed system keeps hn’s standard status bar. Ctrl+b, then c opens a terminal in a new tab. Saved `~/projects` files are copiedand verified during installation. The full TUI reference and OS guide are bundledfor agent questions. **Super+n/t/m/i/w** require no Shift; Ctrl+b bindings still work.The installer selects a disk, focuses Password, and has one full-width-**Install Harness** action. Progress shows only the current step; encrypted boot shows the+**Install Harness** action, one row tall and aligned with the fields. Progress shows the Harness wordmark above the current step; encrypted boot shows theHarness wordmark and a masked password prompt.Both the live and installed system use `me@harness`.`Super+u` opens Updates. Frequent hn/CLI releases download in the background;@@ -29,15 +29,16 @@ you choose when to reconnect the screen. Running agents and terminals stay aliveThe update checker records release ancestry so a source-built runtime cannot bereplaced by an older public CLI with a higher development version number.-[Download preview 9](https://github.com/autonomous-ai/openharness/releases/tag/os-v0.1.0-preview.9)+[Download preview 10](https://github.com/autonomous-ai/openharness/releases/tag/os-v0.1.0-preview.10)· [Mac → USB → ThinkPad installation guide](INSTALL.md)· [Standalone HTML/CSS landing page](../website/public/os/README.md)· [Development feedback loop and Mac support targets](DEVELOPMENT.md)-Preview 9 briefly retries a busy encrypted-device close after the installed disk-has been unmounted. A persistent holder still reports an error; cleanup failures-also preserve any earlier installation error. A ThinkPad running preview 8 reached-Harness after normal shutdown and USB removal despite this final cleanup error.+Preview 10 removes a second connection check that reopened Wi-Fi after successful+setup. Encrypted installation now requests deferred device removal after syncing+and unmounting the disk. A remaining device reader can finish without making a+completed installation appear to fail; a slow udev wait has a bounded fallback.+Write, sync and unmount failures still stop installation and remain visible.Preview 8 introduced stronger USB payload compression and fixed a startup race: openinga terminal immediately can no longer send the USB welcome into that new window.@@ -147,9 +148,8 @@ In the current source, the USB asks for a network connection before openingOpenCode. Choose **Install without connecting** to install immediately offline.Ethernet skips the network step when already connected. During a trial, click**Install Harness**, press **Super+i**, or ask the agent to open installation.-F10 focuses Install Harness in the footer; Enter opens the form. New Harness-and Connect a computer introduce multiple agents and computers; dismiss those-starter panels with their close button when the agent needs the whole screen.+F10 focuses Install Harness in the footer; Enter opens the form. Use Super+n for another agent or Super+m to connect a computer. The two right+panes are ordinary terminals.Saved files under `~/projects`, including Git history, are transferred into theinstalled home and verified by hash. Work elsewhere remains temporary. Running@@ -160,7 +160,7 @@ trial files; use the installation guide shipped with your image.The installer uses `me@harness`. Choose **Disk**, leave **Encryption** enabled orchange it, then enter **Password** and **Repeat password**. **Install immediately-erases the selected disk**, as disclosed in the form. There is no second+erases the selected disk**, when you activate Install Harness. There is no secondconfirmation screen. The live USB and mounted disks are excluded. Selecting adisk alone does not write to it. Passwords must be nonempty; this preview uses aUS keyboard layout, including at disk unlock.diff --git a/os/installer.py b/os/installer.pyindex 145aac1c1..634a79836 100644--- a/os/installer.py+++ b/os/installer.py@@ -85,27 +85,44 @@ def log_diagnostic(message):pass+def mapping_active(mapper):+ # /dev nodes can outlive a successful removal while udev is stalled. Ask+ # the kernel through sysfs, not the stale node which caused the timeout.+ root = Path('/sys/class/block')+ if not root.is_dir():+ raise OSError('Cannot inspect the installed disk mapping.')+ for device in root.iterdir():+ if not device.name.startswith('dm-'):+ continue+ try:+ if (device / 'dm/name').read_text().strip() == mapper:+ return True+ except FileNotFoundError:+ pass # A concurrent last close removed this mapping.+ return False++def close_install_mapping(mapper, timeout=10):- """Wait briefly for device probes; never force removal of an active mapping."""- deadline = time.monotonic() + timeout- while True:+ """After successful unmount, let the kernel close any remaining device reader."""+ try:+ # A filesystem probe may outlive unmount. Deferred removal is immediate+ # when unused, otherwise the kernel removes the device on its last close.+ # Never force removal, and never call this after a failed unmount.+ run('cryptsetup', 'close', '--deferred', mapper, timeout=timeout)+ except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as error:+ if isinstance(error, subprocess.CalledProcessError) and error.returncode != 5:+ raise+ log_diagnostic(f'Device close is waiting for a reader or udev: {error}')+ if not mapping_active(mapper):+ return # The ioctl completed before cryptsetup's udev wait timed out.+ # Do not wait for unrelated udev work again. This uses the same deferred+ # kernel removal, with no force, table replacement or skipped disk flush.try:- run('cryptsetup', 'close', mapper, timeout=max(0.01, deadline - time.monotonic()))- return- except subprocess.CalledProcessError as error:- # cryptsetup documents 5 as a busy/existing device. Other failures- # are not transient and must retain their original diagnostics.- if error.returncode != 5 or time.monotonic() >= deadline:+ run('dmsetup', 'remove', '--deferred', '--noudevsync', mapper, timeout=3)+ except (subprocess.CalledProcessError, subprocess.TimeoutExpired):+ if mapping_active(mapper):raise- # udev may still be inspecting the filesystem after unmount. Wait- # for queued probes without allowing an unrelated stuck event to- # hold up shutdown forever. A persistent holder remains an error.- try:- run('udevadm', 'settle', '--timeout=1',- timeout=max(0.01, min(2, deadline - time.monotonic())))- except (subprocess.CalledProcessError, subprocess.TimeoutExpired):- pass- time.sleep(max(0, min(0.25, deadline - time.monotonic())))+ # The final reader can also leave between the check and removal.def partitions(disk):@@ -193,7 +210,7 @@ def validate_image_account(passwd, username):def preflight(config, source):- for command in ['sgdisk', 'udevadm', 'mkfs.fat', 'mkfs.btrfs', 'cryptsetup',+ for command in ['sgdisk', 'udevadm', 'mkfs.fat', 'mkfs.btrfs', 'cryptsetup', 'dmsetup','mount', 'umount', 'btrfs', 'unsquashfs', 'arch-chroot', 'blkid']:if not shutil.which(command):raise ValueError(f'The installer is missing {command}. Boot an intact Harness image.')@@ -496,6 +513,8 @@ class InstallForm:if row >= height or width < 5:returnattr = (curses.A_REVERSE if active else self.accent if accent else curses.A_NORMAL) | (curses.A_BOLD if bold else 0)+ if active:+ text = text.ljust(self.width)self.screen.addnstr(row, self.left, text, min(self.width, width - self.left - 1), attr)def cursor(self, visible):@@ -604,15 +623,14 @@ class InstallForm:label = disk_label(disk, self.width - 18 - len(suffix)) + suffixself.line(4, f"{'Disk':18}{label}", self.focus == 0)self.line(6, f"{'Encryption':18}[{'x' if self.encrypt else ' '}]", self.focus == 1)- capacity = min(32, self.width - 21)+ capacity = self.width - 20for index, label in enumerate(('Password', 'Repeat password')):position = self.positions[index]offset = max(0, position - capacity + 1)mask = '*' * len(self.passwords[index][offset:offset + capacity])self.line(8 + index * 2, f'{label:<18}[{mask:<{capacity}}]', self.focus == index + 2)self.line(12, self.error)- for row, text in [(13, ''), (14, 'Install Harness'), (15, '')]:- self.line(row, text.center(self.width), active=True, bold=self.focus == 4)+ self.line(14, 'Install Harness'.center(self.width), active=True, bold=self.focus == 4)self.cursor(self.focus in (2, 3))if self.focus in (2, 3):position = self.positions[self.focus - 2]@@ -705,7 +723,12 @@ def install_with_progress(screen, config, source, target):screen.erase()height, width = screen.getmaxyx()if height > 0 and width > 1:- screen.addnstr(height // 2, max(0, (width - len(message)) // 2), message, width - 1)+ middle = height // 2+ if height >= 8:+ for row, word in enumerate(WORDMARK):+ screen.addnstr(middle - 3 + row, max(0, (width - len(word)) // 2), word,+ width - 1, view.accent)+ screen.addnstr(min(height - 1, middle + 1), max(0, (width - len(message)) // 2), message, width - 1)screen.refresh()def progress(message):diff --git a/os/lock.json b/os/lock.jsonindex 8e6d6139d..bc94e72a6 100644--- a/os/lock.json+++ b/os/lock.json@@ -1,8 +1,12 @@{- "version": "0.1.0-preview.9",+ "version": "0.1.0-preview.10","arch_snapshot": "2026/10/01","architecture": "x86_64","upgrades_from": [+ {+ "version": "0.1.0-preview.9",+ "arch_snapshot": "2026/10/01"+ },{"version": "0.1.0-preview.8","arch_snapshot": "2026/10/01"diff --git a/os/network.py b/os/network.pyindex 6f827cacc..2da19c60f 100644--- a/os/network.py+++ b/os/network.py@@ -156,16 +156,25 @@ class NetworkPage:self.networks, self.wired, self.selected, self.message = [], [], 0, ''screen.keypad(True)screen.timeout(800)+ self.accent = curses.A_BOLD+ try:+ if curses.has_colors():+ curses.start_color()+ curses.use_default_colors()+ curses.init_pair(1, curses.COLOR_YELLOW, -1)+ self.accent = curses.color_pair(1) | curses.A_BOLD+ except curses.error:+ passtry:curses.curs_set(0)except curses.error:pass- def line(self, row, text, selected=False):+ def line(self, row, text, selected=False, accent=False):height, width = self.screen.getmaxyx()if 0 <= row < height - 1 and width > 3:self.screen.addnstr(row, self.left, fit(text, self.width), self.width,- curses.A_REVERSE if selected else curses.A_NORMAL)+ curses.A_REVERSE if selected else self.accent if accent else curses.A_NORMAL)def begin(self):self.screen.erase()@@ -173,14 +182,15 @@ class NetworkPage:self.width = max(1, min(64, width - 4))self.left = max(0, (width - self.width) // 2)for row, text in enumerate(WORDMARK):- self.line(row + 1, text.center(self.width))- self.line(4, 'Welcome to Harness' if self.first_use else 'Connect to Wi-Fi')- self.line(5, 'Connect to Wi-Fi to get started.' if self.first_use else 'Choose a network.')+ self.line(row + 1, text.center(self.width), accent=True)+ if self.first_use:+ self.line(4, 'The operating system built by agents, for agents.'.center(self.width))+ self.line(7, 'Connect to Wi-Fi to get started' if self.first_use else 'Connect to Wi-Fi')return heightdef refresh(self):self.begin()- self.line(8, 'Finding Wi-Fi…')+ self.line(9, 'Finding Wi-Fi…')self.screen.refresh()self.message = ''try:@@ -262,10 +272,10 @@ class NetworkPage:elif kind == 'wired':label = 'Ethernet ' + value[0]else:- label = {'rescan': 'Rescan', 'install': 'Install without connecting', 'offline': 'Continue offline'}[kind]- self.line(8 + index - offset, label, index == self.selected)+ label = '[ Rescan ]'+ self.line(9 + index - offset, label, index == self.selected)if self.first_use:- self.line(height - 4, 'Install without connecting' if self.live else 'Continue offline',+ self.line(height - 4, '[ Install without connecting ]' if self.live else '[ Continue offline ]',self.selected == len(rows) - 1)self.line(height - 2, self.message or ('' if self.networks else 'No Wi-Fi networks found. Rescan or use Ethernet.'))self.screen.refresh()diff --git a/os/onboarding.py b/os/onboarding.pyindex 8e5ab3e98..5ce24549b 100644--- a/os/onboarding.py+++ b/os/onboarding.py@@ -7,7 +7,6 @@ import subprocessdef welcome():live = Path('/etc/harness-live').is_file()- offline = Falsewhile True:# The network page advances as soon as connected. The live account can# run it without an administrator password.@@ -15,7 +14,6 @@ def welcome():if result.returncode == 0:breakif result.returncode == 11 and not live:- offline = Truebreakif result.returncode == 10 and live:try:@@ -34,7 +32,7 @@ def welcome():(state / 'onboarded').touch()except (OSError, subprocess.TimeoutExpired):pass- os.execv('/usr/bin/hn-os', ['hn-os', 'try', *(['--offline'] if offline else [])])+ os.execv('/usr/bin/hn-os', ['hn-os', 'try'])if __name__ == '__main__':diff --git a/os/root/usr/lib/harness-os/session-settings.py b/os/root/usr/lib/harness-os/session-settings.pynew file mode 100644index 000000000..6dd76f0c3--- /dev/null+++ b/os/root/usr/lib/harness-os/session-settings.py@@ -0,0 +1,40 @@+#!/usr/bin/env python3+"""Migrate earlier OS defaults through hn's API after its saved session attaches."""+from pathlib import Path+import subprocess+import time+++def hn(*args):+ return subprocess.run(['/usr/bin/hn', *args], check=True, text=True,+ capture_output=True, timeout=3).stdout.strip()+++def migrate():+ # hn deliberately restores server options across screen restarts and boots.+ # Remove only our old footer, retaining any footer the user chose themselves.+ if hn('show-options', '-gv', 'status-right') == '#{@harness-update}':+ if hn('show-options', '-gv', 'status-right-length') == '60':+ hn('set-option', '-gu', 'status-right-length')+ hn('set-option', '-gu', 'status-right')+ # The current config already sets this on a new server. An older saved+ # server can lack it; -o preserves an explicit user choice and -q is quiet.+ hn('set-option', '-goq', '@hn-new-window', 'shell')+++def main():+ if Path('/etc/harness-live').exists():+ return+ deadline = time.monotonic() + 15+ while True:+ try:+ migrate()+ return+ except (OSError, subprocess.SubprocessError):+ if time.monotonic() >= deadline:+ raise+ time.sleep(.2)+++if __name__ == '__main__':+ main()diff --git a/os/root/usr/lib/systemd/user/hn-screen.service b/os/root/usr/lib/systemd/user/hn-screen.serviceindex 888664069..8e90eab2d 100644--- a/os/root/usr/lib/systemd/user/hn-screen.service+++ b/os/root/usr/lib/systemd/user/hn-screen.service@@ -19,6 +19,9 @@ Environment=BROWSER=hn-browserExecStartPre=/usr/bin/python3 /usr/lib/harness-os/projects.py prepareWorkingDirectory=-%h/projectsExecStart=/usr/bin/foot --config=/usr/share/harness-os/foot.ini /usr/bin/hn+# Old saved hn servers retain OS settings even after a package update. Migrate+# those defaults via hn's API; a failed migration must not stop the terminal.+ExecStartPost=-/usr/bin/python3 /usr/lib/harness-os/session-settings.pyRestart=alwaysRestartSec=1RestartSteps=5diff --git a/os/root/usr/share/harness-os/guide.md b/os/root/usr/share/harness-os/guide.mdindex ff2071fcb..b7b625084 100644--- a/os/root/usr/share/harness-os/guide.md+++ b/os/root/usr/share/harness-os/guide.md@@ -65,7 +65,7 @@ Useful terminal defaults (verify with `hn list-keys` if customized):| Ctrl+b, then Shift+n | New Harness || Ctrl+b, then Shift+t | New terminal || Ctrl+b, then s | Find harnesses across connected computers |-| Ctrl+b, then c | New tab |+| Ctrl+b, then c | New tab with a terminal || Ctrl+b, then n / p | Next / previous tab || Ctrl+b, then o / arrow | Next pane / pane in that direction || Ctrl+b, then z | Zoom or restore the focused pane |diff --git a/os/root/usr/share/harness-os/tmux-live.conf b/os/root/usr/share/harness-os/tmux-live.confindex f9eee4380..5286a58ce 100644--- a/os/root/usr/share/harness-os/tmux-live.conf+++ b/os/root/usr/share/harness-os/tmux-live.conf@@ -4,5 +4,9 @@ unbind Ubind I os-action install# Share the window list's row; only this button owns the install click target.+set -g status-style 'fg=black,bg=green'+set -g window-status-style 'fg=black,bg=green'+set -g window-status-current-style 'fg=green,bg=black,bold'+set -g status-right-style 'fg=black,bg=green'set -g status-right '#{?#{e|>=:#{client_width},80},Make Harness your OS. ,}#[range=user|os-install bold][ Install Harness ]#[norange]'set -g status-right-length 48diff --git a/os/root/usr/share/harness-os/tmux.conf b/os/root/usr/share/harness-os/tmux.confindex 9822e586f..fb4cbd760 100644--- a/os/root/usr/share/harness-os/tmux.conf+++ b/os/root/usr/share/harness-os/tmux.conf@@ -4,8 +4,8 @@ unbind Dunbind C-zbind W os-action wifibind U new-window -n Updates '/usr/bin/harness updates'-set -g status-right '#{@harness-update}'-set -g status-right-length 60+# Keep hn's normal installed status bar. A new tab is immediately a terminal.+set -g @hn-new-window shellset -g @hn-animations offset -g exit-empty offset -g exit-unattached offdiff --git a/os/tests/essentials_vm.py b/os/tests/essentials_vm.pyindex 76f41e9b5..9fc64b63c 100644--- a/os/tests/essentials_vm.py+++ b/os/tests/essentials_vm.py@@ -139,6 +139,24 @@ def wireless(vm, result):'grep -Fx harness-wifi-success; then exit 0; fi; sleep 1; done; exit 1', timeout=100)vm.command('find /etc/NetworkManager/system-connections -name "*.nmconnection" -exec stat -c "%a %U %n" {} \\;')result['checks'].append('Wireless reconnects after a radio off/on cycle using its stored profile')+ # The AP has DHCP, DNS and HTTP but no upstream Internet. NM can report+ # "connected (site only)"; this must not reopen Wi-Fi in the agent pane.+ # Run the complete packaged onboarding, not just its network sub-form.+ vm.command('nmcli connection modify ' + SSID + ' ipv4.never-default yes ipv6.never-default yes; '+ 'nmcli connection up ' + SSID, timeout=45)+ vm.command('LC_ALL=C nmcli -t -f STATE general > /tmp/wifi-local-state.txt')+ state = vm.read_file('/tmp/wifi-local-state.txt').decode().strip()+ assert state.startswith('connected (') and state != 'connected', state+ (vm.folder / 'wifi-local-state.txt').write_text(state + '\n')+ vm.command(USER_ENV + 'hn new-window -n Connected ' + shlex.quote('/usr/bin/hn-os welcome'))+ vm.command(USER_ENV + 'sh -c ' + shlex.quote('for n in $(seq 1 60); do '+ 'test "$(hn list-panes -F "#{pane_id}" | wc -l)" -eq 3 && exit 0; sleep .5; done; exit 1'), timeout=40)+ vm.command("! pgrep -f '[/]usr/lib/harness-os/network[.]py'")+ vm.command(USER_ENV + 'hn capture-pane -p > /tmp/wifi-onboarded.txt')+ assert b'Connect to Wi-Fi' not in vm.read_file('/tmp/wifi-onboarded.txt')+ vm.screenshot('wifi-04-onboarded-without-second-prompt')+ result['checks'].append('Full onboarding opens three panes on a saved local-only Wi-Fi connection without asking for Wi-Fi again')+ vm.command('nmcli connection modify ' + SSID + ' ipv4.never-default no ipv6.never-default no')# The full-page offline action returns an explicit install result; Esc does# not strand a first-time user in an empty shell.vm.command('nmcli device disconnect "$(cat /run/harness-station)"')diff --git a/os/tests/fast_update_vm.py b/os/tests/fast_update_vm.pyindex 70a42e8d7..bf2d5b952 100644--- a/os/tests/fast_update_vm.py+++ b/os/tests/fast_update_vm.py@@ -67,8 +67,20 @@ def exercise(vm, fixture, host_url):vm.command('for n in $(seq 1 120); do test -s ' + state + '/ready.json && exit 0; sleep .5; done; ''sudo journalctl _UID=1000 _SYSTEMD_USER_UNIT=harness-update.service --no-pager; ''systemctl --user status harness-update.timer harness-update.service --no-pager; exit 1', timeout=75)- wait_text(vm, 'update ready', 'fast-01-notice', status_bar=True)- checks = ['An already-included public CLI release is ignored before staging; independent newer hn and CLI releases remain eligible', 'User timer discovers, verifies and stages a real hn release without changing the running selection']+ # The installed OS uses hn's standard footer. Availability belongs to the+ # Updates screen, which must still expose the timer's staged release.+ vm.command('hn show-options -gv status-right > /tmp/fast-footer.txt')+ footer = vm.read_file('/tmp/fast-footer.txt').decode()+ assert 'local_machine' in footer and '%H:%M' in footer and '@harness-update' not in footer, footer+ vm.keys('meta_l', 'u')+ wait_text(vm, 'an update is ready', 'fast-01-ready')+ vm.keys('esc')+ # Closing the shell is asynchronous. The OS shortcut reuses a named Updates+ # window, so reopening before its removal can select the closing window and+ # make OCR accept its old frame before the next Enter reaches a live screen.+ vm.command('for n in $(seq 1 80); do hn list-windows -F "#{window_name}" > /tmp/fast-windows.txt && '+ '! grep -Fx Updates /tmp/fast-windows.txt && exit 0; sleep .25; done; exit 1', timeout=30)+ checks = ['An already-included public CLI release is ignored before staging; independent newer hn and CLI releases remain eligible', 'User timer discovers, verifies and stages a real hn release without changing the running selection', 'Super+u shows the prepared update while the installed footer stays hn’s standard footer']vm.command('test ! -e ' + state + '/current')def alive(name):diff --git a/os/tests/installer-cleanup-native.py b/os/tests/installer-cleanup-native.pyindex 73da35fe4..c9171e556 100644--- a/os/tests/installer-cleanup-native.py+++ b/os/tests/installer-cleanup-native.py@@ -11,6 +11,7 @@ import subprocessimport tempfileimport threadingimport time+from unittest.mock import patchdef main():@@ -75,6 +76,12 @@ def main():assert mapped.exists()result['checks'].append('Unmodified close returns 5 with the filesystem unmounted and a device reader open')+ def wait_removed():+ deadline = time.monotonic() + 5+ while mapped.exists() and time.monotonic() < deadline:+ time.sleep(.05)+ assert not mapped.exists(), 'Kernel did not remove the mapping after its last reader closed'+timer = threading.Timer(1.5, os.close, args=(holder,))timer.start()holder = None # The joined timer owns this descriptor now.@@ -83,34 +90,65 @@ def main():installer.close_install_mapping(mapper)timer.join()timer = None- assert not mapped.exists()+ wait_removed()result['transient_close_seconds'] = round(time.monotonic() - retried, 3)- result['checks'].append('Cleanup waits for the temporary reader and removes the mapping normally')+ result['checks'].append('Cleanup schedules safe removal while a temporary reader finishes')open_mapping()holder = os.open(mapped, os.O_RDONLY)persistent = time.monotonic()- try:- with installer.command_log(output / 'persistent-close.log'):- installer.close_install_mapping(mapper, timeout=1)- except (subprocess.CalledProcessError, subprocess.TimeoutExpired):- pass- else:- raise AssertionError('A persistent holder must not become success')+ with installer.command_log(output / 'persistent-close.log'):+ installer.close_install_mapping(mapper, timeout=2)assert mapped.exists()result['persistent_close_seconds'] = round(time.monotonic() - persistent, 3)assert result['persistent_close_seconds'] < 3- result['checks'].append('A persistent reader remains an error within the deadline and is never forcibly removed')+ result['checks'].append('An unmounted device with a persistent reader is queued for removal, never forced closed')os.close(holder)holder = None+ wait_removed()+ # Inject the actual subprocess timeout seen on the ThinkPad;+ # the fallback still operates on a real held dm-crypt device.+ open_mapping()+ holder = os.open(mapped, os.O_RDONLY)+ original_run = installer.run+ def slow_cryptsetup(*command, **kwargs):+ if command[0] == 'cryptsetup':+ subprocess.run(['sleep', '2'], check=True, timeout=.05)+ return original_run(*command, **kwargs)+ with installer.command_log(output / 'timeout-close.log'), patch.object(installer, 'run', side_effect=slow_cryptsetup):+ installer.close_install_mapping(mapper)+ assert mapped.exists()+ os.close(holder)+ holder = None+ wait_removed()+ result['checks'].append('A real subprocess timeout falls back to deferred kernel removal without udev synchronization')+ # Cleanup must not depend on the udev queue making progress.+ # Some cryptsetup versions also remove the node themselves,+ # so record that observation instead of requiring a stale node.+ open_mapping()+ run('udevadm', 'control', '--stop-exec-queue')+ try:+ stalled = time.monotonic()+ with installer.command_log(output / 'stalled-udev-close.log'):+ installer.close_install_mapping(mapper, timeout=.5)+ assert not installer.mapping_active(mapper)+ result['stalled_udev_close_seconds'] = round(time.monotonic() - stalled, 3)+ result['stale_node_observed'] = mapped.exists()+ assert result['stalled_udev_close_seconds'] < 4+ finally:+ run('udevadm', 'control', '--start-exec-queue')+ run('udevadm', 'settle', '--timeout=5')+ wait_removed()+ result['checks'].append('Cleanup completes within its bound with the real udev queue stopped; kernel state confirms removal')# Reopen the same filesystem and verify the completed data was# not modified by either failed or retried close operation.+ open_mapping()run('mount', mapped, mount)assert (mount / 'marker').read_text() == 'keep the completed installation\n'assert (mount / 'home' / 'project').read_text() == 'keep the trial project\n'run('umount', '-R', mount)installer.close_install_mapping(mapper)- result['checks'].append('The filesystem remains intact after the failed close and closes after its reader leaves')+ result['checks'].append('The filesystem and project remain intact after deferred removal and timeout recovery')finally:if timer is not None:timer.join(timeout=5)diff --git a/os/tests/test_first_use.py b/os/tests/test_first_use.pyindex 5fe228683..5ac245398 100644--- a/os/tests/test_first_use.py+++ b/os/tests/test_first_use.py@@ -32,15 +32,15 @@ class FirstUse(unittest.TestCase):self.assertEqual(hn_os.opencode_cpu_ready(), ready)with patch.object(hn_os, 'opencode_cpu_ready', return_value=False), \patch.object(hn_os.sys.stdin, 'isatty', return_value=True), patch('builtins.input') as wait, \- patch.object(hn_os, 'connected') as connected, patch.object(hn_os.os, 'execv') as execute:+ patch.object(hn_os, 'wifi') as network, patch.object(hn_os.os, 'execv') as execute:hn_os.try_harness()- connected.assert_not_called()+ network.assert_not_called()execute.assert_not_called()wait.assert_called_once()- def test_connected_machine_starts_bundled_agent_without_model_or_config_override(self):+ def test_agent_launch_never_reopens_network_setup_or_overrides_model_configuration(self):with tempfile.TemporaryDirectory() as temp, patch.object(hn_os.Path, 'home', return_value=Path(temp)), \- patch.object(hn_os, 'connected', return_value=True), patch.object(hn_os, 'wifi') as wifi, \+ patch.object(hn_os, 'wifi') as wifi, \patch.object(hn_os.os, 'chdir') as cwd, patch.object(hn_os.os, 'execv') as execute, \patch.object(hn_os.subprocess, 'check_output', return_value=str(Path(temp) / 'projects/opencode-2026-10-04-09-05')):hn_os.try_harness()@@ -48,35 +48,11 @@ class FirstUse(unittest.TestCase):cwd.assert_called_once_with(str(Path(temp) / 'projects/opencode-2026-10-04-09-05'))execute.assert_called_once_with('/usr/bin/opencode', ['opencode'])- def test_disconnected_or_cancelled_network_setup_never_launches_agent(self):- for outcome in [0, 1]:- with self.subTest(outcome=outcome), patch.object(hn_os, 'connected', return_value=False), \- patch.object(hn_os, 'wifi', return_value=outcome) as wifi, \- patch.object(hn_os.sys.stdin, 'isatty', return_value=False), \- patch.object(hn_os.os, 'execv') as execute:- hn_os.try_harness()- wifi.assert_called_once()- execute.assert_not_called()-- def test_network_setup_flows_into_agent_when_connection_succeeds(self):- with tempfile.TemporaryDirectory() as temp, patch.object(hn_os.Path, 'home', return_value=Path(temp)), \- patch.object(hn_os, 'connected', side_effect=[False, True]), \- patch.object(hn_os, 'wifi', return_value=0), patch.object(hn_os.os, 'chdir'), \- patch.object(hn_os.os, 'execv') as execute, \- patch.object(hn_os.subprocess, 'check_output', return_value=str(Path(temp) / 'projects/opencode-2026-10-04-09-05')):- hn_os.try_harness()- execute.assert_called_once_with('/usr/bin/opencode', ['opencode'])-def test_install_never_requires_network_setup(self):with patch.object(hn_os.sys, 'argv', ['hn-os', 'install']), \patch.object(hn_os.os, 'execv', side_effect=SystemExit) as execute, \- patch.object(hn_os, 'connected') as connected:+ patch.object(hn_os, 'wifi') as network:with self.assertRaises(SystemExit):hn_os.main()self.assertEqual(execute.call_args.args[1], ['python3', '/usr/lib/harness-os/install.py'])- connected.assert_not_called()-- def test_local_only_and_disconnected_states_require_network_setup(self):- for state, expected in [('connected', True), ('connected (local only)', False), ('disconnected', False)]:- with self.subTest(state=state), patch.object(hn_os.subprocess, 'run', return_value=subprocess.CompletedProcess([], 0, state + '\n')):- self.assertEqual(hn_os.connected(), expected)+ network.assert_not_called()diff --git a/os/tests/test_installer.py b/os/tests/test_installer.pyindex 3387a221f..f7d091143 100644--- a/os/tests/test_installer.py+++ b/os/tests/test_installer.py@@ -200,40 +200,58 @@ class EncryptionMemory(unittest.TestCase):class InstallerCleanup(unittest.TestCase):- def test_transient_reader_is_retried_without_force_or_deferred_removal(self):- attempts = []- def command(*args, **kwargs):- if args[:2] == ('cryptsetup', 'close'):- attempts.append(args)- if len(attempts) < 3:- raise subprocess.CalledProcessError(5, args)- elif args[0] == 'udevadm':- # A queued unrelated event can outlast settle's brief budget.- raise subprocess.CalledProcessError(1, args)- with patch.object(installer, 'run', side_effect=command), patch.object(installer.time, 'sleep'):+ def test_mapping_state_comes_from_kernel_names_and_tolerates_a_last_close(self):+ with tempfile.TemporaryDirectory() as temp:+ root = Path(temp)+ name = root / 'dm-0/dm/name'+ name.parent.mkdir(parents=True)+ name.write_text('hn-install-test\n')+ (root / 'sda').mkdir()+ with patch.object(installer, 'Path', return_value=root):+ self.assertTrue(installer.mapping_active('hn-install-test'))+ self.assertFalse(installer.mapping_active('another-mapping'))+ name.unlink()+ self.assertFalse(installer.mapping_active('hn-install-test'))++ def test_deferred_close_does_not_wait_for_or_force_a_remaining_reader(self):+ with patch.object(installer, 'run') as command:+ installer.close_install_mapping('hn-install-test')+ command.assert_called_once_with('cryptsetup', 'close', '--deferred', 'hn-install-test', timeout=10)++ def test_slow_udev_or_busy_close_queues_kernel_removal_without_waiting_for_udev(self):+ for error in [subprocess.CalledProcessError(5, ['cryptsetup', 'close']),+ subprocess.TimeoutExpired(['cryptsetup', 'close'], 4.66)]:+ with self.subTest(error=error), patch.object(installer, 'mapping_active', return_value=True), \+ patch.object(installer, 'run', side_effect=[error, None]) as command:+ installer.close_install_mapping('hn-install-test')+ self.assertEqual(command.call_args_list[-1].args,+ ('dmsetup', 'remove', '--deferred', '--noudevsync', 'hn-install-test'))+ self.assertEqual(command.call_args_list[-1].kwargs, {'timeout': 3})++ def test_timeout_after_successful_removal_is_already_clean(self):+ with patch.object(installer, 'mapping_active', return_value=False), \+ patch.object(installer, 'run', side_effect=subprocess.TimeoutExpired(['cryptsetup'], 10)) as command:installer.close_install_mapping('hn-install-test')- self.assertEqual(attempts, [('cryptsetup', 'close', 'hn-install-test')] * 3)+ self.assertEqual(command.call_count, 1)- def test_persistent_holder_remains_an_error_with_a_bounded_wait(self):- error = subprocess.CalledProcessError(5, ['cryptsetup', 'close', 'hn-install-test'])- def command(*args, **kwargs):- if args[0] == 'cryptsetup':- raise error- started = installer.time.monotonic()- with patch.object(installer, 'run', side_effect=command):+ def test_last_reader_can_close_between_kernel_check_and_deferred_removal(self):+ with patch.object(installer, 'mapping_active', side_effect=[True, False]), \+ patch.object(installer, 'run', side_effect=[subprocess.TimeoutExpired(['cryptsetup'], 10),+ subprocess.CalledProcessError(1, ['dmsetup'])]):+ installer.close_install_mapping('hn-install-test')++ def test_unexpected_close_error_and_failed_deferred_removal_remain_errors(self):+ error = subprocess.CalledProcessError(4, ['cryptsetup', 'close'])+ with patch.object(installer, 'run', side_effect=error) as command:+ with self.assertRaises(subprocess.CalledProcessError) as caught:+ installer.close_install_mapping('hn-install-test')+ self.assertIs(caught.exception, error)+ self.assertEqual(command.call_count, 1)+ with patch.object(installer, 'mapping_active', return_value=True), \+ patch.object(installer, 'run', side_effect=[subprocess.TimeoutExpired(['cryptsetup'], 10), error]):with self.assertRaises(subprocess.CalledProcessError) as caught:- installer.close_install_mapping('hn-install-test', timeout=0.02)- self.assertIs(caught.exception, error)- self.assertLess(installer.time.monotonic() - started, 1)-- def test_unexpected_close_error_and_timeout_are_not_retried(self):- for error in [subprocess.CalledProcessError(4, ['cryptsetup', 'close']),- subprocess.TimeoutExpired(['cryptsetup', 'close'], 10)]:- with self.subTest(error=error), patch.object(installer, 'run', side_effect=error) as command:- with self.assertRaises(type(error)) as caught:- installer.close_install_mapping('hn-install-test')- self.assertIs(caught.exception, error)- self.assertEqual(command.call_count, 1)+ installer.close_install_mapping('hn-install-test')+ self.assertIs(caught.exception, error)def failed_install(self, unmount_failure=False, log_failure=False):config = dict(username='me', hostname='harness', password='private-password',@@ -292,7 +310,7 @@ class Screen:clear = erase- def addnstr(self, row, column, text, length, attr):+ def addnstr(self, row, column, text, length, attr=0):self.drawn.append(text[:length])def addstr(self, row, column, text, attr):diff --git a/os/tests/test_network.py b/os/tests/test_network.pyindex 6d6b764c1..468cf5bd3 100644--- a/os/tests/test_network.py+++ b/os/tests/test_network.py@@ -82,7 +82,7 @@ class Network(unittest.TestCase):screen, page = self.page(['\x1b', '\x03', 'r', 'i'])self.assertEqual(page.run(), network.INSTALL)text = '\n'.join(text for _, text in screen.lines)- self.assertIn('Welcome to Harness', text)+ self.assertIn('The operating system built by agents, for agents.', text)self.assertLess(text.index('a:network'), text.index('Ethernet'))self.assertIn('Rescan', text)self.assertIn('Install without connecting', text)@@ -99,6 +99,13 @@ class Network(unittest.TestCase):self.assertNotIn('right-password', text)self.assertIn('*****', text)+ def test_connected_site_or_local_network_skips_setup_without_an_internet_probe(self):+ for state, expected in [('connected', True), ('connected (site only)', True),+ ('connected (local only)', True), ('connecting', False),+ ('disconnected', False), ('asleep', False)]:+ with self.subTest(state=state), patch.object(network, 'nmcli', return_value=result(output=state)):+ self.assertEqual(network.connected(), expected)+def test_working_ethernet_skips_the_form(self):screen, page = self.page([])with patch.object(network, 'connected', return_value=True), patch.object(network, 'scan') as scan:diff --git a/os/tests/test_onboarding.py b/os/tests/test_onboarding.pyindex d0ab25a26..560246cd4 100644--- a/os/tests/test_onboarding.py+++ b/os/tests/test_onboarding.py@@ -47,7 +47,7 @@ class Onboarding(unittest.TestCase):patch.object(onboarding.subprocess, 'run', side_effect=[result(11), result()]), \patch.object(onboarding.os, 'execv') as execute:onboarding.welcome()- execute.assert_called_once_with('/usr/bin/hn-os', ['hn-os', 'try', '--offline'])+ execute.assert_called_once_with('/usr/bin/hn-os', ['hn-os', 'try'])def test_failed_layout_request_does_not_mark_first_use_complete(self):with tempfile.TemporaryDirectory() as temp, patch.object(onboarding.Path, 'is_file', return_value=False), \diff --git a/os/tests/test_session_settings.py b/os/tests/test_session_settings.pynew file mode 100644index 000000000..583fbe639--- /dev/null+++ b/os/tests/test_session_settings.py@@ -0,0 +1,31 @@+import importlib.util+from pathlib import Path+import unittest+from unittest.mock import patch++spec = importlib.util.spec_from_file_location('session_settings',+ Path(__file__).resolve().parents[1] / 'root/usr/lib/harness-os/session-settings.py')+settings = importlib.util.module_from_spec(spec)+spec.loader.exec_module(settings)+++class SavedSessionSettings(unittest.TestCase):+ def test_old_os_footer_is_reset_to_the_tuis_current_defaults(self):+ with patch.object(settings, 'hn', side_effect=['#{@harness-update}', '60', '', '', '']) as hn:+ settings.migrate()+ self.assertIn((('set-option', '-gu', 'status-right'),), hn.call_args_list)+ self.assertIn((('set-option', '-gu', 'status-right-length'),), hn.call_args_list)+ self.assertEqual(hn.call_args.args, ('set-option', '-goq', '@hn-new-window', 'shell'))++ def test_custom_footer_and_length_are_preserved(self):+ with patch.object(settings, 'hn', side_effect=['my own footer', '']) as hn:+ settings.migrate()+ self.assertEqual(hn.call_count, 2)+ with patch.object(settings, 'hn', side_effect=['#{@harness-update}', '100', '', '']) as hn:+ settings.migrate()+ self.assertNotIn((('set-option', '-gu', 'status-right-length'),), hn.call_args_list)++ def test_usb_configuration_is_not_migrated(self):+ with patch.object(settings.Path, 'exists', return_value=True), patch.object(settings, 'migrate') as migrate:+ settings.main()+ migrate.assert_not_called()diff --git a/os/tests/update_guest.py b/os/tests/update_guest.pyindex 950c63d16..7ab7e40fb 100644--- a/os/tests/update_guest.py+++ b/os/tests/update_guest.py@@ -31,11 +31,15 @@ def main():updater = str(bundle / 'apply-update.py')original_version = version()original_runtime = Path('/usr/share/harness-os/runtime.json').read_text()- project = Path.home() / 'Projects/update-survivor'+ # Preview 9 already uses lowercase projects. Only older installations need+ # migration; creating a second Projects folder must not make an update merge+ # two independent user directories.+ legacy = not (Path.home() / 'projects').is_dir()+ project = Path.home() / ('Projects' if legacy else 'projects') / 'update-survivor'project.mkdir(parents=True, exist_ok=True)(project / 'keep.txt').write_text('keep this project through apply, restart and rollback\n')(project / 'heartbeat.py').write_text('''import os, pathlib, time-root = pathlib.Path.home() / 'Projects/update-survivor'+root = pathlib.Path(__file__).resolve().parent(root / 'pid').write_text(str(os.getpid()))while True:with (root / 'heartbeat').open('a') as output: output.write('alive\\n')@@ -65,6 +69,10 @@ while True:time.sleep(0.1)run('systemctl', '--user', 'is-active', '--quiet', 'hn-screen')alive()+ def updated_settings():+ bar = run('hn', 'show-options', '-gv', 'status-right').stdout+ assert 'local_machine' in bar and '%H:%M' in bar and '@harness-update' not in bar, bar+ assert run('hn', 'show-options', '-gv', '@hn-new-window').stdout.strip() == 'shell'receipt = {'status': 'running', 'checks': [], 'previous_package': original_version,'candidate': manifest['package'], 'source_commit': manifest['source_commit']}broken = bundle.parent / 'broken-bundle'@@ -100,8 +108,11 @@ while True:alive()receipt['checks'].append('Repeated apply recognizes the installed build without another transaction')restart()+ updated_settings()+ receipt['checks'].append('An older saved hn session migrates to the standard TUI footer and terminal-tab default')assert (Path.home() / 'projects/update-survivor/keep.txt').read_text() == (project / 'keep.txt').read_text()- receipt['checks'].append('Legacy Projects migrates to lowercase projects while existing session paths remain valid')+ receipt['checks'].append('Legacy Projects migrates to lowercase projects while existing session paths remain valid'+ if legacy else 'Existing lowercase projects stays in place through the update')receipt['checks'].append('The same terminal process and project survive restarting both Harness daemon and screen')for name, info in manifest['runtime']['files'].items():path = Path('/usr/lib/harness') / namediff --git a/os/tests/update_vm.py b/os/tests/update_vm.pyindex 65717a06f..6d8ca8b49 100644--- a/os/tests/update_vm.py+++ b/os/tests/update_vm.py@@ -82,8 +82,20 @@ def main():vm.login_installed(config)manifest = json.loads((bundle / 'package-manifest.json').read_text())vm.command('test "$(pacman -Q harness-os)" = ' + shlex.quote('harness-os ' + manifest['package']['version']))- vm.command('test -s ~/Projects/update-survivor/keep.txt')+ vm.command('test -s ~/projects/update-survivor/keep.txt')receipt['keyboard'] = check_graphical_keyboard(vm, 'updated')+ vm.command('hn show-options -gv status-right > /tmp/updated-footer.txt')+ bar = vm.read_file('/tmp/updated-footer.txt').decode()+ assert 'local_machine' in bar and '%H:%M' in bar and '@harness-update' not in bar, bar+ vm.keys('ctrl', 'b')+ vm.keys('c')+ time.sleep(1)+ vm.type_probe('echo updated-tab-ready')+ vm.keys('ret')+ vm.command('for n in $(seq 1 20); do hn capture-pane -p | grep -qx updated-tab-ready && exit 0; sleep .5; done; exit 1', timeout=15)+ vm.screenshot('updated-standard-footer-terminal-tab')+ vm.keys('ctrl', 'd')+ receipt['checks'].append('A rebooted upgrade preserves hn’s standard footer and Ctrl+b, c opens a real terminal tab')receipt['checks'].append('Updated encrypted machine reboots to hn, accepts physical-keyboard input and retains the project')if args.fast_fixture:vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')@@ -95,7 +107,7 @@ def main():vm.stop()vm.start(live=False)vm.login_installed(config)- vm.command('test ! -e /run/harness-os-restart-required; test -s ~/Projects/update-survivor/keep.txt')+ vm.command('test ! -e /run/harness-os-restart-required; test -s ~/projects/update-survivor/keep.txt')receipt['system_channel']['reboot_keyboard'] = check_graphical_keyboard(vm, 'system-channel-reboot')receipt['checks'].append('The OS-channel update boots its rebuilt encrypted image and accepts keyboard input')receipt['status'] = 'passed'diff --git a/os/tests/vm.py b/os/tests/vm.pyindex 33bfe6181..86ae179f5 100644--- a/os/tests/vm.py+++ b/os/tests/vm.py@@ -464,6 +464,17 @@ if (rows.some(row => row.engine !== 'terminal')) throw new Error('A plain shellvm.command(user('sh -c ' + shlex.quote('for n in $(seq 1 30); do ''hn list-panes -a -F "#{pane_id}" | grep -Fx ' + shlex.quote(pane.group(1)) +' >/dev/null || exit 0; sleep .25; done; exit 1')), timeout=15)+ # The OS opts into hn's existing shell-tab setting; test real prefix keys,+ # since invoking new-window through the CLI already opened a shell before.+ vm.keys('ctrl', 'b')+ vm.keys('c')+ time.sleep(1)+ vm.type_probe('echo prefix-tab-ready')+ vm.keys('ret')+ vm.command(user('sh -c ' + shlex.quote('for n in $(seq 1 20); do hn capture-pane -p | grep -qx prefix-tab-ready && exit 0; sleep .5; done; exit 1')), timeout=15)+ vm.screenshot('01c-prefix-terminal-tab')+ vm.keys('ctrl', 'd')+ time.sleep(.5)vm.monitor('set_link', name='hnnet', up=True)vm.command('nmcli networking on; for n in $(seq 1 30); do test "$(nmcli -t -f STATE general)" = connected && exit 0; sleep 1; done; exit 1', timeout=40)vm.command('for n in $(seq 1 90); do pgrep -u 1000 -x opencode >/dev/null && exit 0; sleep 1; done; exit 1', timeout=100)@@ -497,6 +508,9 @@ if (rows.some(row => row.engine !== 'terminal')) throw new Error('A plain shellvm.command(user('hn display-message -p "#{E:status-right}"') + ' > /tmp/hn-first-footer.txt')footer = vm.read_file('/tmp/hn-first-footer.txt').decode()assert 'Make Harness your OS.' in footer and '[ Install Harness ]' in footer, footer+ vm.command(user('hn show-options -gv status-style') + ' > /tmp/hn-first-footer-style.txt')+ assert vm.read_file('/tmp/hn-first-footer-style.txt').strip() == b'fg=black,bg=green'+ vm.command("! pgrep -f '[/]usr/lib/harness-os/network[.]py'")for index, row in enumerate(right):vm.command(user('hn select-pane -t ' + row[0]))vm.type_probe('echo starter-terminal-' + str(index))@@ -737,7 +751,7 @@ def check_installer_cleanup(vm, folder):(folder / 'cleanup-native.log').write_text(output)finally:failure = sys.exception()- for name in ['receipt.json', 'baseline-close.txt', 'transient-close.log', 'persistent-close.log']:+ for name in ['receipt.json', 'baseline-close.txt', 'transient-close.log', 'persistent-close.log', 'timeout-close.log', 'stalled-udev-close.log']:try:(folder / ('cleanup-' + name)).write_bytes(vm.read_file('/run/hn-cleanup-result/' + name, timeout=10))except Exception as error:@@ -887,7 +901,7 @@ assert str(i.live_payload()) == '/run/archiso/copytoram/airootfs.sfs'returnif args.encrypt:result['installer_cleanup'] = check_installer_cleanup(vm, folder)- result['checks'].append('Packaged installer closes a transiently busy encrypted mapping, preserves its filesystem and rejects a persistent holder')+ result['checks'].append('Packaged installer safely defers transient/persistent encrypted-device readers, recovers a close timeout and preserves the filesystem')config = dict(disk='/dev/vda', expected_serial='HN_OS_TEST', confirm_erase='/dev/vda',username='me', hostname='harness', password='test-password-123',encrypt=args.encrypt, serial_console=True)@@ -916,7 +930,12 @@ assert str(i.live_payload()) == '/run/archiso/copytoram/airootfs.sfs''test "$(hn list-panes -F "#{pane_id}" | wc -l)" -eq 3 && exit 0; sleep .5; done; exit 1', timeout=40)vm.screenshot('installed-first-workspace')vm.command('hn capture-pane -p | grep -qv "Enter.*Start OpenCode"; test -d ~/projects')+ vm.command('hn show-options -gv status-right > /tmp/hn-installed-status.txt')+ installed_bar = vm.read_file('/tmp/hn-installed-status.txt').decode()+ assert 'local_machine' in installed_bar and '%H:%M' in installed_bar and 'Install Harness' not in installed_bar, installed_bar+ vm.command("! pgrep -f '[/]usr/lib/harness-os/network[.]py'")result['checks'].append('Fresh installed first boot opens the same three real panes and records onboarding only once')+ result['checks'].append('Installed first use preserves hn’s full status bar and never reopens networking after the connection succeeds')saved_trial = vm.read_file(trial_project)assert saved_trial == (folder / 'trial-project.html').read_bytes(), 'The installed home lost or changed the agent-created trial project'vm.command('test ! -e /home/me/.config/hn-trial-credential && test "$(stat -c %u ' + shlex.quote(trial_project) + ')" -eq 1000')diff --git a/os/tools/hn-os b/os/tools/hn-osindex da064dcf3..4bb5e69b8 100644--- a/os/tools/hn-os+++ b/os/tools/hn-os@@ -19,12 +19,6 @@ def cpu_ticks():return sum(values), values[3] + values[4]-def connected():- result = subprocess.run(['nmcli', '--wait', '5', '-t', '-f', 'STATE', 'general'],- text=True, capture_output=True, timeout=8, env=dict(os.environ, LC_ALL='C'))- return result.returncode == 0 and result.stdout.strip() == 'connected'--def wifi():return subprocess.call(['sudo', '/usr/bin/python3', '/usr/lib/harness-os/network.py'])@@ -52,19 +46,17 @@ def prepare_opencode_guidance():pass-def try_harness(offline=False):+def try_harness():if not opencode_cpu_ready():print('The bundled OpenCode needs a newer CPU (SSE4.2).')print('Open a terminal to work locally or connect to a remote agent.')if sys.stdin.isatty():input('Press Enter to return to Harness.')return- if not offline and not connected():- if wifi() != 0 or not connected():- print('OpenCode needs an internet connection. Connect to Wi-Fi or plug in Ethernet, then try again.')- if sys.stdin.isatty():- input('Press Enter to return to Harness.')- return+ # First-use networking belongs to onboarding.py. Rechecking here used to+ # reject NetworkManager's "connected (site/local only)" state after a+ # successful Wi-Fi step and reopen the form in the agent's new pane.+ # Later launches also need to support local models and offline work.project = subprocess.check_output(['/usr/bin/python3', '/usr/lib/harness-os/projects.py', 'new', 'opencode'], text=True).strip()prepare_opencode_guidance()os.chdir(project)@@ -81,7 +73,7 @@ def main():if command == 'wifi':raise SystemExit(wifi())if command == 'try':- try_harness(offline='--offline' in args)+ try_harness()returnif command == 'welcome':os.execv('/usr/bin/python3', ['python3', '/usr/lib/harness-os/onboarding.py'])