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
Measure installed OS, agent, and browser footprints separately (#726)
Dee8d1df0e55f47
diff --git a/.github/workflows/os-footprint.yml b/.github/workflows/os-footprint.ymlnew file mode 100644index 000000000..0a2f01c4f--- /dev/null+++ b/.github/workflows/os-footprint.yml@@ -0,0 +1,55 @@+name: Harness OS installed footprint assessment++on:+ workflow_dispatch:+ inputs:+ image_run_id:+ description: 'Exact existing image artifact to assess'+ type: string+ default: '37207405290'+ required: true+ push:+ branches: ['os-polish/footprint-audit']+ paths: ['os/tests/footprint_*.py', 'os/tests/test_footprint.py', '.github/workflows/os-footprint.yml']++permissions:+ contents: read+ actions: read++jobs:+ footprint:+ runs-on: ubuntu-24.04+ timeout-minutes: 20+ strategy:+ fail-fast: false+ matrix:+ memory: [1024, 4096]+ steps:+ - uses: actions/checkout@v7+ - uses: actions/download-artifact@v6+ with:+ name: programmer-os-x86_64+ path: os/dist+ run-id: ${{ inputs.image_run_id || '37207405290' }}+ github-token: ${{ github.token }}+ - name: Check the observer and install VM tools+ run: |+ python3 -m py_compile os/tests/footprint_guest.py os/tests/footprint_vm.py+ python3 -m unittest discover -s os/tests -p test_footprint.py -v+ go run github.com/rhysd/actionlint/cmd/[email protected] .github/workflows/os-footprint.yml+ sudo apt-get update -qq+ sudo apt-get install -y --no-install-recommends qemu-system-x86 qemu-utils ovmf python3-pil tesseract-ocr+ sudo chmod a+rw /dev/kvm+ - name: Measure working agent, agent-free terminal, and browser separately+ run: python3 os/tests/footprint_vm.py --iso os/dist/*.iso --memory-mib '${{ matrix.memory }}'+ - name: Retain measurements without disposable disks+ if: always()+ uses: actions/upload-artifact@v6+ with:+ name: harness-os-footprint-${{ matrix.memory }}+ path: |+ os/test-results/footprint-${{ matrix.memory }}/+ !os/test-results/footprint-${{ matrix.memory }}/*.qcow2+ !os/test-results/footprint-${{ matrix.memory }}/OVMF_VARS.fd+ retention-days: 14+ compression-level: 0diff --git a/os/DEVELOPMENT.md b/os/DEVELOPMENT.mdindex 07efa0c5f..c6f705c35 100644--- a/os/DEVELOPMENT.md+++ b/os/DEVELOPMENT.md@@ -5,9 +5,9 @@ boot changes. Reflashing is a release/install test, not the intended way to tryevery interface fix. Keep the development tools on the build/test host; theinstalled OS keeps the same minimal interface.-This plan was recorded on October 3, 2026. Preview 7 and its small bootstrap bundle-and update channel are published. Its native upgrade from preview 6 passed; earlier-preview 6 coverage includes upgrades from previews 4 and 5. Remote-launcher argument+Preview 10, its small update bundle, and the installed system update channel are+published. Its native upgrade from preview 9 passed; earlier preview 6 coverage+includes upgrades from previews 4 and 5. Remote-launcher argumenttests passed but remote display/SSH interaction is still unverified.## Next release priorities@@ -91,6 +91,36 @@ python3 os/tests/local_ai_vm.py --iso os/dist/IMAGE.iso --probe local-aipython3 os/tests/local_ai_vm.py --iso os/dist/IMAGE.iso --probe nvidia```+The **Harness OS installed footprint assessment** workflow reuses a checksum-verified+published image in fresh encrypted 1 GiB and 4 GiB Nehalem VMs. It samples the+default OpenCode workspace, stops the disposable agent to measure the terminal,+then renders a local Chromium page. Each state settles for 20 seconds before ten+samples at two-second intervals. Receipts retain MemAvailable-based system usage,+swap, interval CPU, process PSS/RSS, package metadata and screenshots. Actual+graphical keyboard checks run after agent shutdown and return from the browser.+The background update timer is stopped during sampling and restarted afterward.++Dispatch `os-footprint.yml` with `image_run_id`, or use a native x86 KVM host:++```sh+python3 os/tests/footprint_vm.py --iso os/dist/IMAGE.iso --memory-mib 1024+python3 os/tests/footprint_vm.py --iso os/dist/IMAGE.iso --memory-mib 4096+```++[Preview 10 results](https://github.com/autonomous-ai/openharness/actions/runs/37212080839)+are summarized in the [footprint table](README.md#measured-preview-footprint).+The two runs passed; test source was `f00ab7429584c982ed7a1b5a23ad82f3d4de579f`.+Terminal-only median CPU was about 0.75%; the observer and diagnostic login remain+included. This is one ordered sequence per VM with a software-rendered display,+not a randomized comparison, physical hardware benchmark or model throughput test.++The inventory records 405 packages. Its largest logical sizes belong to Chromium+(422 MiB), OpenCode (195 MiB), LLVM (165 MiB), the LTS kernel (156 MiB), and device+firmware. The installed USB boot/recovery tools examined total about 10.84 MiB+logical size; that is not a demonstrated saving. Package sizes are uncompressed,+and missing metadata remains unknown. Retain hardware support and recovery tools+until a candidate removal has dependency, actual disk-saving and recovery evidence.+The **Harness OS runtime memory assessment** workflow compares Node flags in oneinstalled 1 GiB VM. It alternates two default and two candidate rounds, samplesRSS/PSS and local status latency with four persistent terminal streams, records@@ -227,7 +257,7 @@ OS windows use hn's local session storage (`HARNESS_TUI_DESK=off`), so theirlayout and pane references survive reconnects without signing into the cloud.This setting is confined to the OS launcher; ordinary hn installs are unchanged.-`Update ready · Super+u` appears in the bottom bar. Super+u opens the keyboard+The installed system keeps hn's standard status bar. Super+u opens the keyboardupdate action (Ctrl+b, Shift+u remains an alias). Enter applies the preparedruntime through a transient user service. An hn-only change reconnects just thescreen; a CLI change also restarts its supervised service. Failure restores thediff --git a/os/README.md b/os/README.mdindex 14a466d94..7745c03e1 100644--- a/os/README.md+++ b/os/README.md@@ -177,7 +177,8 @@ and, when enabled, the disk. There is no first-boot account wizard.`--config` file, set `username`, `hostname` and `encrypt` in that file instead.Ordinary hn on macOS or another Linux distribution does not expose OS installation.-On the installed system's empty home, Enter starts OpenCode. Super+n starts New+The installed system's first workspace opens OpenCode on the left and two terminal+panes on the right; later launches restore existing work. Super+n starts NewHarness, Super+t opens a shell directly, Super+m connects a computer, Super+wopens Wi-Fi and Super+l locks the session. These require no Shift or prefix.The shared TUI shortcuts still work: Ctrl+b, then Shift+n/t/w for the corresponding@@ -187,10 +188,10 @@ normal Linux administrator control.## Updates and recovery-Preview 5 prepares hn/CLI releases automatically and shows a small bottom-bar-notice. `Super+u` opens Updates; Enter activates an available runtime and-reconnects the screen without a computer reboot. **R** restores the previous-runtime. System updates use **S**, ask for the account password, retain a+The installed system prepares hn/CLI releases automatically and keeps hn's standard+status bar. `Super+u` opens Updates; Enter activates an available runtime and+reconnects the screen without a computer reboot. **r** restores the previous+runtime. System updates use **s**, ask for the account password, retain acheckpoint and offer a restart when ready. Neither channel automaticallyinterrupts working agents. See [update development](DEVELOPMENT.md#fast-hn-updates).@@ -270,6 +271,27 @@ separately in `progress.json`.## Measured preview footprint+Preview 10's ISO is 1,668,448,256 bytes (1.55 GiB). Its+[installed footprint assessment](https://github.com/autonomous-ai/openharness/actions/runs/37212080839)+used the published image `2eee2748c2290f5700695922d7e12589033ee3c3` in fresh+two-vCPU, encrypted UEFI VMs. Installed root usage, including home and snapshots,+was 2.04 GiB. Ten samples per state give these medians:++| Installed state | RAM used, 1 GiB VM | Swap used, 1 GiB VM | RAM used, 4 GiB VM |+| --- | --- | --- | --- |+| OpenCode and two terminal panes | 678.7 MiB | 30.4 MiB | 827.8 MiB |+| Terminal, agent and browser closed | 392.3 MiB | 23.9 MiB | 525.4 MiB |+| Local browser page, agent closed | 476.5 MiB | 170.7 MiB | 828.8 MiB |++The 4 GiB VM used no swap. RAM means `MemTotal - MemAvailable`; diagnostic login+and the observer remain included. The browser's low resident usage in the 1 GiB+VM comes with substantially more swap. Each VM runs one ordered sequence, so+these figures describe those states rather than proving a causal difference.+OpenCode is idle; this does not measure active agent work or local inference.+Both VMs rendered the browser page and accepted keyboard input on return to hn.++### Earlier installation and boot measurements+These measurements cover preview 6 image `3c15fe540de02db8a3b37d565ce8b4001b872779`.The ISO is 1,748,402,176 bytes (1.63 GiB). The table records two-vCPU, 1 GiB VMs.[1 GiB USB tests](https://github.com/autonomous-ai/openharness/actions/runs/37149350400)diff --git a/os/tests/footprint_guest.py b/os/tests/footprint_guest.pynew file mode 100644index 000000000..01d77845a--- /dev/null+++ b/os/tests/footprint_guest.py@@ -0,0 +1,151 @@+#!/usr/bin/env python3+"""Read-only footprint samples inside a disposable installed Harness guest."""+import argparse+import json+import os+from pathlib import Path+import statistics+import subprocess+import time+++def fields(text):+ return {name.rstrip(':'): int(value.split()[0])+ for name, value in (line.split(':', 1) for line in text.splitlines() if ':' in line)}+++def cpu(text):+ # guest/guest_nice are already included in user/nice; never count them twice.+ values = list(map(int, text.splitlines()[0].split()[1:9]))+ if len(values) != 8:+ raise ValueError('Incomplete aggregate CPU counters')+ return sum(values), values[3] + values[4]+++def cpu_busy(before, after):+ total = after[0] - before[0]+ idle = after[1] - before[1]+ if total <= 0 or not 0 <= idle <= total:+ raise ValueError('Invalid CPU counter interval')+ return round(100 * (total - idle) / total, 3)+++def memory(text):+ value = fields(text)+ total, available = value['MemTotal'], value['MemAvailable']+ if not 0 <= available <= total or not 0 <= value['SwapFree'] <= value['SwapTotal']:+ raise ValueError('Invalid memory counters')+ return dict(total_kib=total, available_kib=available, used_kib=total - available,+ swap_used_kib=value['SwapTotal'] - value['SwapFree'])+++def process_groups():+ groups, vanished = {}, 0+ for entry in Path('/proc').iterdir():+ if not entry.name.isdecimal():+ continue+ try:+ name = (entry / 'comm').read_text().strip()+ # Aggregate equal names, including all OpenCode/browser children.+ data = fields((entry / 'smaps_rollup').read_text())+ except (FileNotFoundError, ProcessLookupError):+ vanished += 1+ continue+ row = groups.setdefault(name, dict(processes=0, rss_kib=0, pss_kib=0, swap_pss_kib=0))+ row['processes'] += 1+ row['rss_kib'] += data['Rss']+ row['pss_kib'] += data['Pss']+ row['swap_pss_kib'] += data.get('SwapPss', 0)+ return dict(groups=groups, processes_without_userspace_map=vanished)+++def package_fields(text):+ result, key = {}, None+ for line in text.splitlines():+ if line.startswith('%') and line.endswith('%'):+ key = line[1:-1]+ result[key] = []+ elif line and key:+ result[key].append(line)+ return result+++def package_row(text):+ value = package_fields(text)+ # SIZE is optional (notably for metapackages). Preserve an absent value as+ # unrecorded rather than inventing measured savings or rejecting the sample.+ # https://man.archlinux.org/man/alpm-db-desc.5.en#%SIZE%+ size = int(value['SIZE'][0]) if value.get('SIZE') else None+ if size is not None and size < 0:+ raise ValueError('Negative installed package size')+ row = dict(name=value['NAME'][0], version=value['VERSION'][0],+ uncompressed_bytes=size, explicit=value.get('REASON', ['0']) == ['0'],+ depends=value.get('DEPENDS', []))+ if size is None:+ row.update(size_status='not recorded', database_fields=sorted(value))+ return row+++def inventory():+ packages = []+ for path in Path('/var/lib/pacman/local').glob('*/desc'):+ packages.append(package_row(path.read_text()))+ packages.sort(key=lambda row: (row['uncompressed_bytes'] is None,+ -(row['uncompressed_bytes'] or 0), row['name']))+ usage = os.statvfs('/')+ directories = subprocess.run(['du', '-x', '-B1', '-d', '2', '/usr', '/var', '/opt'],+ capture_output=True, text=True, timeout=120, check=True).stdout+ return dict(packages=packages, directory_allocated_bytes=directories,+ root_used_bytes_including_home_and_snapshots=(usage.f_blocks-usage.f_bfree)*usage.f_frsize,+ package_size_note='Pacman SIZE is logical/uncompressed; do not equate it with compressed Btrfs savings.')+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument('--phase', choices=['agent-workspace', 'terminal-only', 'browser'], required=True)+ parser.add_argument('--output', type=Path, required=True)+ args = parser.parse_args()+ if (os.getuid() != 0 or Path('/etc/harness-live').exists() or+ not Path('/run/harness-footprint-disposable').is_file() or+ not Path('/var/lib/harness-os/install.json').is_file()):+ parser.error('Run only as root in the marked disposable installed VM')+ result = dict(status='running', phase=args.phase, started_at=time.time(), samples=[],+ observer_pid=os.getpid(), note='Observer and diagnostic serial login are included. PSS apportions shared pages.')+ args.output.parent.mkdir(parents=True, exist_ok=True)+ try:+ # Match settling and sample duration across states; no cache dropping.+ time.sleep(20)+ previous = cpu(Path('/proc/stat').read_text())+ for _ in range(10):+ time.sleep(2)+ current = cpu(Path('/proc/stat').read_text())+ row = dict(at=time.time(), memory=memory(Path('/proc/meminfo').read_text()),+ cpu_busy_percent=cpu_busy(previous, current), **process_groups())+ opencode = row['groups'].get('opencode', {}).get('processes', 0)+ browser = row['groups'].get('chromium', {}).get('processes', 0)+ if args.phase == 'agent-workspace' and not opencode:+ raise RuntimeError('OpenCode is absent from the working-state sample')+ if args.phase != 'agent-workspace' and opencode:+ raise RuntimeError('The agent is still running in an agent-free sample')+ if args.phase == 'browser' and not browser:+ raise RuntimeError('Chromium is absent from the browser sample')+ if args.phase != 'browser' and browser:+ raise RuntimeError('Unexpected browser in a terminal/agent sample')+ result['samples'].append(row)+ previous = current+ result.update(status='passed', median_used_mib=statistics.median(+ row['memory']['used_kib'] / 1024 for row in result['samples']),+ median_cpu_busy_percent=statistics.median(row['cpu_busy_percent'] for row in result['samples']),+ median_swap_used_mib=statistics.median(row['memory']['swap_used_kib'] / 1024 for row in result['samples']))+ if args.phase == 'terminal-only':+ result['inventory'] = inventory()+ except BaseException as error:+ result.update(status='failed', error=repr(error))+ raise+ finally:+ result['finished_at'] = time.time()+ args.output.write_text(json.dumps(result, indent=2) + '\n')+++if __name__ == '__main__':+ main()diff --git a/os/tests/footprint_vm.py b/os/tests/footprint_vm.pynew file mode 100644index 000000000..69a6fdde7--- /dev/null+++ b/os/tests/footprint_vm.py@@ -0,0 +1,112 @@+#!/usr/bin/env python3+"""Measure the shipped workspace, agent-free terminal and browser on one installation."""+import argparse+import base64+import hashlib+import json+import os+from pathlib import Path+import shlex+import subprocess+import time+from vm import VM, check_graphical_keyboard+++def copy_file(vm, data, destination):+ encoded = base64.b64encode(data).decode()+ vm.command(': > /tmp/footprint-transfer.b64')+ for start in range(0, len(encoded), 2000):+ vm.command('printf %s ' + encoded[start:start+2000] + ' >> /tmp/footprint-transfer.b64')+ vm.command('base64 -d /tmp/footprint-transfer.b64 > ' + shlex.quote(destination))+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument('--iso', type=Path, required=True)+ parser.add_argument('--memory-mib', type=int, choices=[1024, 4096], required=True)+ args = parser.parse_args()+ if not os.access('/dev/kvm', os.R_OK | os.W_OK):+ parser.error('Native x86 KVM is required')+ iso = args.iso.resolve()+ manifest = json.loads(iso.with_name('manifest.json').read_text())+ with iso.open('rb') as handle:+ assert hashlib.file_digest(handle, 'sha256').hexdigest() == manifest['iso']['sha256']+ folder = Path(f'os/test-results/footprint-{args.memory_mib}').resolve()+ folder.mkdir(parents=True, exist_ok=False)+ vm = VM(folder, iso, 'uefi', args.memory_mib, cpu='Nehalem')+ config = dict(disk='/dev/vda', expected_serial='HN_OS_TEST', confirm_erase='/dev/vda',+ username='me', hostname='harness', password='test-password-123', encrypt=True, serial_console=True)+ result = dict(status='running', started_at=time.time(), image_source_commit=manifest['source_commit'],+ test_source_commit=subprocess.check_output(['git','rev-parse','HEAD'], text=True).strip(),+ iso_sha256=manifest['iso']['sha256'], memory_mib=args.memory_mib, cpu='Nehalem',+ limitations=['One ordered sequence per VM, not randomized repeated performance trials.',+ 'Software-rendered virtual display; no physical GPU or laptop timing claim.',+ 'OpenCode idle/default setup, not a model throughput or code-quality benchmark.'])+ try:+ vm.start(live=True)+ vm.wait(r'root@[^\r\n]*[#] ', timeout=180)+ vm.shell_ready = True+ vm.command('stty -echo')+ copy_file(vm, json.dumps(config).encode(), '/tmp/install-config.json')+ vm.command('nmcli networking off')+ output, _ = vm.command('harness install --config /tmp/install-config.json --yes-erase-disk', timeout=360)+ (folder / 'install.log').write_text(output)+ vm.command('sync')+ vm.stop()+ vm.start(live=False)+ vm.login_installed(config)+ vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')+ vm.command('sudo -n touch /run/harness-footprint-disposable')+ vm.command('mkdir -p /home/me/footprint-assessment')+ script = Path(__file__).with_name('footprint_guest.py')+ copy_file(vm, script.read_bytes(), '/home/me/footprint-assessment/observe.py')+ # Keep background update downloads out of a short controlled sample.+ vm.command('systemctl --user stop harness-update.timer harness-update.service')+ vm.command('for n in $(seq 1 90); do pgrep -u "$(id -u)" -x opencode >/dev/null && exit 0; sleep 1; done; exit 1', timeout=100)+ vm.boot_diagnostics(config, 'installed')+ result['phases'] = {}+ for phase in ['agent-workspace', 'terminal-only', 'browser']:+ if phase == 'terminal-only':+ # Only this disposable user's bundled trial is stopped; no host process is touched.+ vm.command('pkill -TERM -u "$(id -u)" -x opencode')+ vm.command('for n in $(seq 1 40); do pgrep -u "$(id -u)" -x opencode >/dev/null || exit 0; sleep .25; done; exit 1')+ result['terminal_keyboard'] = check_graphical_keyboard(vm, 'agent-free')+ if phase == 'browser':+ copy_file(vm, b'<!doctype html><title>Harness footprint</title><h1>Harness footprint</h1><p>A local browser preview.</p>', '/home/me/footprint-assessment/preview.html')+ vm.command('hn-browser file:///home/me/footprint-assessment/preview.html')+ deadline = time.monotonic() + 45+ while time.monotonic() < deadline:+ vm.screenshot('browser-visible')+ visible = subprocess.check_output(['tesseract', str(folder / 'browser-visible.png'), 'stdout', '--psm', '11'], text=True, stderr=subprocess.DEVNULL, timeout=10)+ if 'Harness footprint' in visible:+ break+ time.sleep(1)+ else:+ raise RuntimeError('The local browser page did not render')+ path = '/home/me/footprint-assessment/' + phase + '.json'+ output, status = vm.command('sudo -n python3 /home/me/footprint-assessment/observe.py --phase ' + phase + ' --output ' + path, timeout=180, check=False)+ (folder / (phase + '.log')).write_text(output)+ data = vm.read_file(path)+ (folder / (phase + '.json')).write_bytes(data)+ result['phases'][phase] = json.loads(data)+ assert status == 0 and result['phases'][phase]['status'] == 'passed', phase+ vm.screenshot(phase)+ vm.keys('meta_l', 'ret')+ result['after_browser_keyboard'] = check_graphical_keyboard(vm, 'footprint-complete')+ vm.command('systemctl --user start harness-update.timer')+ result['status'] = 'passed'+ except BaseException as error:+ result.update(status='failed', error=repr(error))+ try:+ vm.screenshot('failure')+ except Exception:+ pass+ raise+ finally:+ result['finished_at'] = time.time()+ (folder / 'receipt.json').write_text(json.dumps(result, indent=2) + '\n')+ vm.stop()+++if __name__ == '__main__':+ main()diff --git a/os/tests/test_footprint.py b/os/tests/test_footprint.pynew file mode 100644index 000000000..c2ce40d3e--- /dev/null+++ b/os/tests/test_footprint.py@@ -0,0 +1,44 @@+import unittest+from footprint_guest import cpu, cpu_busy, memory, package_fields, package_row+++class FootprintCounters(unittest.TestCase):+ def test_cpu_does_not_double_count_guest_time(self):+ self.assertEqual(cpu('cpu 10 20 30 40 5 6 7 8 9 10\ncpu0 1 2 3'), (126, 45))+ self.assertEqual(cpu_busy((100, 30), (200, 90)), 40)++ def test_invalid_cpu_intervals_are_not_performance_claims(self):+ for before, after in [((100, 30), (100, 30)), ((100, 30), (90, 20)), ((100, 30), (110, 50))]:+ with self.assertRaises(ValueError):+ cpu_busy(before, after)++ def test_available_not_free_defines_system_memory(self):+ result = memory('MemTotal: 1024 kB\nMemFree: 10 kB\nMemAvailable: 700 kB\nSwapTotal: 512 kB\nSwapFree: 500 kB\n')+ self.assertEqual(result['used_kib'], 324)+ self.assertEqual(result['swap_used_kib'], 12)++ def test_impossible_memory_sample_is_rejected(self):+ with self.assertRaises(ValueError):+ memory('MemTotal: 1024 kB\nMemAvailable: 1025 kB\nSwapTotal: 0 kB\nSwapFree: 0 kB\n')++ def test_package_metadata_retains_all_dependencies(self):+ result = package_fields('%NAME%\nexample\n\n%SIZE%\n12345\n\n%DEPENDS%\nlibc\nother>=2\n\n%REASON%\n1\n')+ self.assertEqual(result['DEPENDS'], ['libc', 'other>=2'])+ self.assertEqual(result['SIZE'], ['12345'])+ self.assertEqual(result['REASON'], ['1'])++ def test_optional_size_does_not_invent_zero_byte_savings(self):+ result = package_row('%NAME%\nbase\n\n%VERSION%\n3-1\n\n%DEPENDS%\nsystemd\n')+ self.assertIsNone(result['uncompressed_bytes'])+ self.assertEqual(result['size_status'], 'not recorded')+ self.assertTrue(result['explicit'])++ def test_recorded_zero_and_negative_size_are_distinct(self):+ text = '%NAME%\nexample\n\n%VERSION%\n1-1\n\n%SIZE%\n'+ self.assertEqual(package_row(text + '0\n')['uncompressed_bytes'], 0)+ with self.assertRaises(ValueError):+ package_row(text + '-1\n')+++if __name__ == '__main__':+ unittest.main()