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
Explain the bundled agent CPU limit before installation (#815)
Deee7b31792b984
diff --git a/os/hardware.py b/os/hardware.pyindex 40dac2724..1be5555ea 100644--- a/os/hardware.py+++ b/os/hardware.py@@ -83,19 +83,28 @@ def needs_broadcom(device):return device['driver'] == 'wl' or not any(i['wireless'] for i in device['interfaces'])-def report(sysfs=Path('/sys'), proc=Path('/proc')):- fields = {}+def opencode_cpu_supported(proc=Path('/proc')):+ """Return None when the x86 instruction requirement cannot be determined."""+ architecture = os.uname().machine+ if architecture != 'x86_64' and not re.fullmatch(r'i[3-6]86', architecture):+ return None+ flags = []for line in read(proc / 'cpuinfo').splitlines():- if ':' in line:- key, value = line.split(':', 1)- fields.setdefault(key.strip(), value.strip())- flags = fields.get('flags')+ key, separator, value = line.partition(':')+ if separator and key.strip() == 'flags':+ flags.append(value.split())+ if not flags or any(not features for features in flags):+ return None+ return all('sse4_2' in features for features in flags)+++def report(sysfs=Path('/sys'), proc=Path('/proc')):return {'architecture': os.uname().machine, 'kernel': os.uname().release,'computer': {'vendor': read(sysfs / 'class/dmi/id/sys_vendor') or None,'model': read(sysfs / 'class/dmi/id/product_name') or None},'efi_bits': read(sysfs / 'firmware/efi/fw_platform_size') or None,'opencode_cpu': {'required_x86_feature': 'sse4_2',- 'available': 'sse4_2' in flags.split() if flags is not None else None},+ 'available': opencode_cpu_supported(proc)},'pci': pci_devices(sysfs),'installation_blocker': installation_blocker(sysfs),'backlights': [p.name for p in sorted((sysfs / 'class/backlight').glob('*'))],diff --git a/os/installer.py b/os/installer.pyindex 620b10a0f..5e6cd8d1d 100644--- a/os/installer.py+++ b/os/installer.py@@ -29,17 +29,27 @@ INSTALL_LOG = Path('/var/log/harness-install.log')LAST_LOG = None-def require_install_platform(sysfs=Path('/sys')):+def hardware_module():# Load the root-owned packaged sibling, never a module from the working- # directory. Only tests supply a different sysfs root.+ # directory.spec = importlib.util.spec_from_file_location('harness_os_hardware', Path(__file__).with_name('hardware.py'))hardware = importlib.util.module_from_spec(spec)spec.loader.exec_module(hardware)- blocker = hardware.installation_blocker(sysfs)+ return hardware+++def require_install_platform(sysfs=Path('/sys')):+ blocker = hardware_module().installation_blocker(sysfs)if blocker:raise ValueError(blocker)+def installation_notice():+ if hardware_module().opencode_cpu_supported() is False:+ return 'This CPU cannot run bundled OpenCode (SSE4.2 required).'+ return ''++def encryption_memory(meminfo=Path('/proc/meminfo')):"""Budget Argon2 against RAM, not zram advertised as additional swap."""try:@@ -536,12 +546,13 @@ def disk_label(disk, width=None):class InstallForm:"""Small keyboard form using the Python/ncurses already in the image."""- def __init__(self, screen, candidates, username, hostname, encrypt):+ def __init__(self, screen, candidates, username, hostname, encrypt, notice=''):self.screen, self.disks = screen, candidatesself.username, self.hostname, self.encrypt = username, hostname, encryptself.selected, self.focus = 0, 2self.passwords, self.positions = ['', ''], [0, 0]self.error = ''+ self.notice = noticeself.title = Noneself.cursor_visible = Noneself.top, self.left, self.width = 0, 2, 60@@ -675,6 +686,8 @@ class InstallForm:while True:if not self.begin(''):continue+ for row, line in enumerate(textwrap.wrap(self.notice, self.width)):+ self.line(1 + row, line, accent=True)disk = self.disks[self.selected]# Identical models/capacities need a visible discriminator after selection.duplicate = sum(disk_label(d) == disk_label(disk) for d in self.disks) > 1@@ -745,7 +758,8 @@ def interactive(username='me', hostname='harness', encrypt=True):if not sys.stdin.isatty() or not sys.stdout.isatty():raise ValueError('Interactive installation needs a terminal. Use --config for unattended installation.')curses.set_escdelay(25)- return curses.wrapper(lambda screen: InstallForm(screen, candidates, username, hostname, encrypt).run())+ notice = installation_notice()+ return curses.wrapper(lambda screen: InstallForm(screen, candidates, username, hostname, encrypt, notice).run())def completion(screen, boot=False):diff --git a/os/tests/test_hardware.py b/os/tests/test_hardware.pyindex 22084ca96..5de336022 100644--- a/os/tests/test_hardware.py+++ b/os/tests/test_hardware.py@@ -3,6 +3,7 @@ import jsonfrom pathlib import Pathimport subprocessimport tempfile+from types import SimpleNamespaceimport unittestfrom unittest.mock import patch@@ -12,6 +13,37 @@ hardware = importlib.util.module_from_spec(spec)spec.loader.exec_module(hardware)+class OpenCodeCpu(unittest.TestCase):+ def supported(self, content, architecture='x86_64'):+ with tempfile.TemporaryDirectory() as folder:+ proc = Path(folder)+ if content is not None:+ (proc / 'cpuinfo').write_text(content)+ with patch.object(hardware.os, 'uname', return_value=SimpleNamespace(machine=architecture)):+ return hardware.opencode_cpu_supported(proc)++ def test_core2_and_penryn_lack_the_bundled_requirement(self):+ for flags in ['sse sse2 pni ssse3', 'sse sse2 pni ssse3 sse4_1']:+ with self.subTest(flags=flags):+ self.assertIs(self.supported('flags : ' + flags + '\n'), False)++ def test_nehalem_needs_no_avx(self):+ self.assertIs(self.supported('flags : sse2 ssse3 sse4_1 sse4_2\n'), True)++ def test_missing_empty_or_non_x86_information_is_unknown(self):+ for content in [None, '', 'processor : 0\n', 'flags : \n', 'Features : fp asimd\n']:+ with self.subTest(content=content):+ self.assertIsNone(self.supported(content))+ for architecture in ['aarch64', 'armv7l', 'riscv64']:+ with self.subTest(architecture=architecture):+ self.assertIsNone(self.supported('flags : sse2\n', architecture))++ def test_all_reported_cpus_must_have_the_feature(self):+ self.assertIs(self.supported('flags : sse2 sse4_2\n\nflags : sse2\n'), False)+ self.assertIs(self.supported('flags : sse2 sse4_2\n\nflags : sse2 sse4_2\n'), True)+ self.assertIsNone(self.supported('flags : sse2 sse4_2\n\nflags : \n'))++class HardwarePolicy(unittest.TestCase):def setUp(self):self.temp = tempfile.TemporaryDirectory()@@ -277,6 +309,9 @@ class HardwarePolicy(unittest.TestCase):hardware.bundle_manifest(live, all_files=True)def test_report_does_not_collect_serials_network_addresses_or_ssids(self):+ uname = hardware.os.uname()+ self.enterContext(patch.object(hardware.os, 'uname',+ return_value=SimpleNamespace(machine='x86_64', release=uname.release)))self.device()dmi = self.sysfs / 'class/dmi/id'dmi.mkdir(parents=True)diff --git a/os/tests/test_installer.py b/os/tests/test_installer.pyindex a317f7457..2d505417b 100644--- a/os/tests/test_installer.py+++ b/os/tests/test_installer.py@@ -134,6 +134,18 @@ class PlatformSafety(unittest.TestCase):installer.require_install_platform(self.root / 'missing-sysfs')+class CpuNotice(unittest.TestCase):+ def test_notice_is_only_for_a_known_missing_instruction(self):+ hardware = installer.hardware_module()+ for supported in [False, True, None]:+ with self.subTest(supported=supported), \+ patch.object(installer, 'hardware_module', return_value=hardware), \+ patch.object(hardware, 'opencode_cpu_supported', return_value=supported):+ self.assertEqual(installer.installation_notice(),+ 'This CPU cannot run bundled OpenCode (SSE4.2 required).'+ if supported is False else '')++class LivePayload(unittest.TestCase):def test_usb_ram_copy_and_mounted_media_are_both_supported(self):with tempfile.TemporaryDirectory() as temp:@@ -473,6 +485,7 @@ class InteractiveInstall(unittest.TestCase):context.enter_context(patch.object(installer.sys.stdin, 'isatty', return_value=True))context.enter_context(patch.object(self.output, 'isatty', return_value=True))self.install = context.enter_context(patch.object(installer, 'install'))+ self.cpu_notice = context.enter_context(patch.object(installer, 'installation_notice', return_value=''))self.payload = context.enter_context(patch.object(installer, 'live_payload', return_value=Path('/test-live.sfs')))self.secret = 'test-password-123'@@ -503,6 +516,32 @@ class InteractiveInstall(unittest.TestCase):self.assertTrue(any(row.startswith(f'{label:18}') for row in first.splitlines()))for frame in self.screen.frames:self.assertNotIn(self.secret, frame)+ self.assertNotIn('SSE4.2', frame)++ def test_cpu_notice_is_visible_before_install_without_an_extra_step(self):+ self.cpu_notice.return_value = 'This CPU cannot run bundled OpenCode (SSE4.2 required).'+ self.fill_passwords()+ self.confirm()+ installer.main()+ self.assertIn(self.cpu_notice.return_value, self.screen.frames[0])+ self.install.assert_called_once()+ self.assertEqual(self.install.call_args.args[0]['password'], self.secret)+ self.cpu_notice.assert_called_once()++ def test_cpu_notice_wraps_above_fields_in_the_smallest_form(self):+ self.screen.size = (18, 54)+ self.cpu_notice.return_value = 'This CPU cannot run bundled OpenCode (SSE4.2 required).'+ self.screen.keys.append('\x1b')+ with self.assertRaises(KeyboardInterrupt):+ installer.main()+ first = self.screen.frames[0]+ self.assertIn(self.cpu_notice.return_value, ' '.join(first.splitlines()))+ for row, _, text, _ in self.screen.attributes:+ if 'This CPU' in text or 'required).' in text:+ self.assertLess(row, 4)+ for label in ('Disk', 'Encryption', 'Password', 'Repeat password'):+ self.assertIn(label, first)+ self.install.assert_not_called()def test_short_password_is_accepted_but_empty_password_is_not(self):self.secret = 'a'