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
Test actual USB payload mode across memory sizes (#746)
Deee85260491050
diff --git a/.github/workflows/os.yml b/.github/workflows/os.ymlindex 25298b130..1379dc91d 100644--- a/.github/workflows/os.yml+++ b/.github/workflows/os.yml@@ -30,11 +30,11 @@ on:required: falsetype: stringmemory_mib:- description: 'VM RAM; 1024 exercises constrained machines, 4096 enables automatic USB copy-to-RAM'+ description: 'VM RAM; 1024 exercises constrained machines, 6144 requires USB copy-to-RAM'required: falsedefault: '2048'type: choice- options: ['2048', '1024', '4096']+ options: ['2048', '1024', '4096', '6144']live_transport:description: 'Boot the ISO as a virtual optical disc or a writable USB with a private overlay'required: false@@ -204,7 +204,15 @@ jobs:OS_WORKLOAD_SOURCE_RUN: ${{ inputs.workload_seed_run_id }}OS_MEMORY_MIB: ${{ inputs.memory_mib || '2048' }}OS_LIVE_TRANSPORT: ${{ inputs.live_transport || 'cdrom' }}- run: python3 os/tests/vm.py --iso os/dist/*.iso --memory "$OS_MEMORY_MIB" --live-transport "$OS_LIVE_TRANSPORT" --firmware '${{ matrix.firmware }}' ${{ matrix.encryption }} ${{ matrix.agents }} ${{ matrix.cpu }} ${{ (inputs.workloads || inputs.workload_seed_run_id != '') && matrix.firmware == 'bios' && '--workloads' || '' }} ${{ inputs.dsh && matrix.firmware == 'bios' && '--dsh' || '' }} ${{ inputs.workload_seed_run_id != '' && matrix.firmware == 'bios' && '--workload-seed os/work/workload-seed' || '' }} ${{ inputs.workloads && inputs.workload_seed_run_id != '' && matrix.firmware == 'bios' && '--workload-repair-game' || '' }}+ run: |+ live_mode=()+ if [[ "$OS_LIVE_TRANSPORT" == usb ]]; then+ case "$OS_MEMORY_MIB" in+ 1024) live_mode=(--expect-live-mode media) ;;+ 6144) live_mode=(--expect-live-mode ram) ;;+ esac+ fi+ python3 os/tests/vm.py --iso os/dist/*.iso --memory "$OS_MEMORY_MIB" --live-transport "$OS_LIVE_TRANSPORT" "${live_mode[@]}" --firmware '${{ matrix.firmware }}' ${{ matrix.encryption }} ${{ matrix.agents }} ${{ matrix.cpu }} ${{ (inputs.workloads || inputs.workload_seed_run_id != '') && matrix.firmware == 'bios' && '--workloads' || '' }} ${{ inputs.dsh && matrix.firmware == 'bios' && '--dsh' || '' }} ${{ inputs.workload_seed_run_id != '' && matrix.firmware == 'bios' && '--workload-seed os/work/workload-seed' || '' }} ${{ inputs.workloads && inputs.workload_seed_run_id != '' && matrix.firmware == 'bios' && '--workload-repair-game' || '' }}- name: Exercise password lock and actual suspend/resumeif: ${{ inputs.checks == 'session' }}run: python3 os/tests/session_vm.py --iso os/dist/*.iso --firmware '${{ matrix.firmware }}' --session-file os/root/usr/lib/harness-os/session --theme-directory os/root/usr/share/plymouth/themes/harnessdiff --git a/os/DEVELOPMENT.md b/os/DEVELOPMENT.mdindex 7204bcadc..ba4e53d44 100644--- a/os/DEVELOPMENT.md+++ b/os/DEVELOPMENT.md@@ -271,8 +271,11 @@ a clean USB install to verify that upgrades have not hidden an installation bug.UEFI/encrypted install, boot, wrong-password retry, update and recovery checks.It retains screenshots, boot-stage timestamps, logs and source/image identity.- `image_run_id` tests an existing image without rebuilding it. `memory_mib=1024`- exercises a constrained machine; `memory_mib=4096` and `live_transport=usb`- exercise automatic copy-to-RAM. `workloads=true` or `dsh=true` runs the relevant+ exercises a constrained machine; `memory_mib=6144` and `live_transport=usb`+ require automatic copy-to-RAM. The USB test verifies its actual payload mount+ and refuses the boot USB as an installation target in both modes. The 4 GiB+ check permits either mode: Archiso copies only when available memory exceeds+ the compressed payload plus 2 GiB. `workloads=true` or `dsh=true` runs the relevantreal-agent exercises. See the [measured evidence](README.md#real-programmer-exercises).- `workload_seed_run_id` preserves generated projects and reruns their acceptancechecks without another model turn. Enable `workloads=true` as well only whendiff --git a/os/tests/test_vm_control.py b/os/tests/test_vm_control.pyindex 692de840e..31b20d8d9 100644--- a/os/tests/test_vm_control.py+++ b/os/tests/test_vm_control.py@@ -33,5 +33,30 @@ class MonitorCommands(unittest.TestCase):vm_module.control_point(words, 'Install', 1280, 800, 2, 24)+class LiveMedia(unittest.TestCase):+ def test_automatic_mode_records_the_observed_media(self):+ vm = Mock()+ vm.command.return_value = ('HN_LIVE_MEDIA={"mode":"media","boot_usb_rejected":true}\n', 0)+ result = {'checks': []}+ vm_module.check_live_media(vm, result)+ self.assertEqual(result['live_media']['mode'], 'media')+ self.assertEqual(len(result['checks']), 2)++ def test_required_ram_path_cannot_pass_using_the_usb(self):+ vm = Mock()+ vm.command.return_value = ('HN_LIVE_MEDIA={"mode":"media","boot_usb_rejected":true}\n', 0)+ result = {'checks': []}+ with self.assertRaisesRegex(AssertionError, 'Expected ram boot, observed media'):+ vm_module.check_live_media(vm, result, 'ram')+ self.assertEqual(result['checks'], [])+ self.assertEqual(result['live_media']['mode'], 'media')++ def test_missing_guest_result_never_passes(self):+ vm = Mock()+ vm.command.return_value = ('shell prompt only', 0)+ with self.assertRaisesRegex(AssertionError, 'did not report'):+ vm_module.check_live_media(vm, {'checks': []})++if __name__ == '__main__':unittest.main()diff --git a/os/tests/vm.py b/os/tests/vm.pyindex 2ec91f0a2..7fe8e0a79 100644--- a/os/tests/vm.py+++ b/os/tests/vm.py@@ -37,6 +37,53 @@ def control_point(words, word, width, height, scale, border):return round(x * 32767 / (width - 1)), round(y * 32767 / (height - 1))+def check_live_media(vm, result, expected_mode=None):+ # Archiso reserves 2 GiB beyond the compressed payload before copying it.+ # A fixed guest RAM size therefore does not determine the boot mode.+ probe = '''import importlib.util, json+from pathlib import Path+s = importlib.util.spec_from_file_location('installer', '/usr/lib/harness-os/install.py')+i = importlib.util.module_from_spec(s)+s.loader.exec_module(i)+payload = i.live_payload()+ram = Path('/run/archiso/copytoram/airootfs.sfs')+media = Path('/run/archiso/bootmnt/arch/x86_64/airootfs.sfs')+bootmnt = Path('/run/archiso/bootmnt')+assert payload in (ram, media), str(payload)+mode = 'ram' if payload == ram else 'media'+if mode == 'ram':+ assert not bootmnt.exists(), 'RAM boot kept the USB mounted'+ assert ram.parent.is_mount(), 'RAM payload is not on its own mount'+ assert i.run('findmnt', '-nro', 'FSTYPE', '--mountpoint', str(ram.parent), capture=True).strip() == 'tmpfs'+else:+ assert bootmnt.is_mount(), 'USB payload is not on mounted media'+ assert not ram.exists(), 'Ambiguous live payload'+d = next(d for d in i.inventory() if d.get('serial') == 'HN_OS_LIVE')+assert not d['ro'] and d['size'] >= i.MIN_DISK_BYTES+try:+ i.validate_disk(d)+except ValueError as e:+ assert ('booted into RAM' if mode == 'ram' else 'mounted filesystems') in str(e), str(e)+else:+ raise AssertionError('The writable boot USB was offered as an installation target')+print('HN_LIVE_MEDIA=' + json.dumps(dict(mode=mode, payload=str(payload), payload_bytes=payload.stat().st_size, boot_usb_rejected=True)))+'''+ encoded = base64.b64encode(probe.encode()).decode()+ output, _ = vm.command('printf %s ' + encoded + ' | base64 -d | python3')+ match = re.search(r'HN_LIVE_MEDIA=(\{[^\r\n]+\})', output)+ assert match, 'The guest did not report its actual live media'+ media = json.loads(match.group(1))+ result['live_media'] = media+ if expected_mode and media['mode'] != expected_mode:+ raise AssertionError(f"Expected {expected_mode} boot, observed {media['mode']}")+ if media['mode'] == 'ram':+ result['checks'].append('Real USB boot automatically copies the payload into RAM and unmounts the boot medium')+ result['checks'].append('The unmounted writable Harness USB is rejected as an installation target in RAM mode')+ else:+ result['checks'].append('Real USB boot retains the mounted payload when automatic RAM copying is not selected')+ result['checks'].append('The mounted writable Harness USB is rejected as an installation target')++class VM:def __init__(self, folder, iso, firmware, memory, live_transport='cdrom', cpu=None, video='virtio-vga', audio=False):self.folder, self.iso, self.firmware, self.memory = folder, iso, firmware, memory@@ -822,6 +869,7 @@ def main():parser.add_argument('--encrypt', action='store_true')parser.add_argument('--memory', type=int, default=2048)parser.add_argument('--live-transport', choices=['cdrom', 'usb'], default='cdrom')+ parser.add_argument('--expect-live-mode', choices=['media', 'ram'], help='Require a specific USB boot path; otherwise validate and record the observed path')parser.add_argument('--cpu', help='Optional QEMU CPU model, for an older instruction-set baseline')parser.add_argument('--output', type=Path)parser.add_argument('--agents', action='store_true', help='Install and start real agent executables after recovery; no accounts/API calls')@@ -831,6 +879,8 @@ def main():parser.add_argument('--workload-repair-game', action='store_true', help='With a seed, explicitly ask the agent to repair game layout before rechecking')parser.add_argument('--live-only', action='store_true', help='Development probe: stop after the live-session checks, without installing')args = parser.parse_args()+ if args.expect_live_mode and args.live_transport != 'usb':+ parser.error('--expect-live-mode requires --live-transport usb')if args.workloads and not args.agents:parser.error('--workloads requires --agents')if args.dsh and not args.agents:@@ -865,28 +915,8 @@ def main():vm.wait(r'root@[^\r\n]*[#] ')vm.shell_ready = Truevm.command('stty -echo')- if args.live_transport == 'usb' and args.memory >= 4096:- vm.command('test -f /run/archiso/copytoram/airootfs.sfs && test ! -e /run/archiso/bootmnt')- result['checks'].append('Real USB boot automatically copies the payload into RAM and unmounts the boot medium')- # The unmounted writable boot USB must still be rejected, even- # though its size otherwise makes it an eligible target.- probe = '''import importlib.util-s = importlib.util.spec_from_file_location('installer', '/usr/lib/harness-os/install.py')-i = importlib.util.module_from_spec(s)-s.loader.exec_module(i)-d = next(d for d in i.inventory() if d.get('serial') == 'HN_OS_LIVE')-assert not d['ro'] and d['size'] >= i.MIN_DISK_BYTES-try:- i.validate_disk(d)-except ValueError as e:- assert 'booted into RAM' in str(e), str(e)-else:- raise AssertionError('The unmounted boot USB was offered as a target')-assert str(i.live_payload()) == '/run/archiso/copytoram/airootfs.sfs'-'''- encoded = base64.b64encode(probe.encode()).decode()- vm.command('printf %s ' + encoded + ' | base64 -d | python3')- result['checks'].append('The unmounted writable Harness USB is rejected as an installation target in RAM mode')+ if args.live_transport == 'usb':+ check_live_media(vm, result, args.expect_live_mode)vm.command('foot --check-config --config=/usr/share/harness-os/foot.ini')if direct:from install_first import check_usb_installer