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
fix(os): include Intel Mac keyboard controllers at disk unlock (#740)
Dee064d1e6d1670
diff --git a/.github/workflows/os-input.yml b/.github/workflows/os-input.ymlindex bf7978365..5c4441e41 100644--- a/.github/workflows/os-input.yml+++ b/.github/workflows/os-input.yml@@ -8,6 +8,12 @@ on:type: stringdefault: '37222390225'required: true+ probe:+ description: 'Laptop media controls or Apple encrypted-boot module closure'+ type: choice+ options: [laptop-input, apple-boot]+ default: laptop-input+ required: truepush:branches: ['os-polish/laptop-input']paths: ['os/tests/input_*.py', 'os/root/usr/share/harness-os/labwc*/rc.xml', '.github/workflows/os-input.yml']@@ -40,15 +46,22 @@ jobs:sudo apt-get install -y --no-install-recommends qemu-system-x86 qemu-utils ovmf python3-pil tesseract-ocrsudo chmod a+rw /dev/kvm- name: Check actual media-key input on USB and installed sessions+ if: ${{ inputs.probe != 'apple-boot' }}run: python3 os/tests/input_vm.py --iso os/dist/*.iso+ - name: Check Apple initramfs selection and encrypted boot+ if: ${{ inputs.probe == 'apple-boot' }}+ run: python3 os/tests/apple_boot_vm.py --iso os/dist/*.iso- name: Retain actual input, module and display evidenceif: always()uses: actions/upload-artifact@v6with:- name: harness-os-laptop-input+ name: harness-os-${{ inputs.probe || 'laptop-input' }}path: |os/test-results/input/+ os/test-results/apple-boot/!os/test-results/input/*.qcow2!os/test-results/input/OVMF_VARS.fd+ !os/test-results/apple-boot/*.qcow2+ !os/test-results/apple-boot/OVMF_VARS.fdretention-days: 14compression-level: 0diff --git a/os/DEVELOPMENT.md b/os/DEVELOPMENT.mdindex 6a666fa13..7204bcadc 100644--- a/os/DEVELOPMENT.md+++ b/os/DEVELOPMENT.md@@ -74,6 +74,22 @@ of one; keyboard controls select only `*::kbd_backlight` LEDs. These use theexisting [brightnessctl options](https://github.com/Hummer12007/brightnessctl).No extra daemon, package, widget or screen is required.+The same workflow's `probe=apple-boot` check installs a checksum-verified image+to an encrypted 1 GiB VM. It uses private mount-namespace DMI fixtures and the+actual `mkinitcpio -P` presets to inspect both pre-T2 SPI controller families.+The baseline includes `applespi` but omits its host controllers; the candidate+must include the controllers, their dependency closure and early module loading,+while retaining existing explicit modules. Negative model fixtures check that+USB-only Macs, T2, Apple Silicon and other PCs are unaffected. Finally it removes+the fixtures, regenerates the generic initramfs and verifies graphical disk+unlock and typing in hn after reboot. Logs, module lists and image hashes are+retained; this is preparation for physical Mac tests, not proof of Apple input.++The small `20-harness-apple-keyboard.conf` mkinitcpio drop-in uses the model and+controller mapping documented by [Linux KEYBOARD_APPLESPI](https://github.com/torvalds/linux/blob/master/drivers/input/keyboard/Kconfig).+It adds the existing in-tree drivers during installation and subsequent initramfs+rebuilds. Do not replace them with the obsolete macbook12 SPI DKMS driver.+`checks=browser` with an `image_run_id` exercises the installed terminal/browsersession in BIOS/plain and UEFI/encrypted VMs. It records and applies only thecandidate `hn-browser` script and labwc configuration over the checksum-verifieddiff --git a/os/root/etc/mkinitcpio.conf.d/20-harness-apple-keyboard.conf b/os/root/etc/mkinitcpio.conf.d/20-harness-apple-keyboard.confnew file mode 100644index 000000000..1671c7da5--- /dev/null+++ b/os/root/etc/mkinitcpio.conf.d/20-harness-apple-keyboard.conf@@ -0,0 +1,11 @@+# The keyboard hook includes applespi, but not its separate SPI host drivers.+# Keep built-in input available before encrypted root is unlocked. These are+# the pre-T2 controller families documented in Linux KEYBOARD_APPLESPI Kconfig.+case "$(cat /sys/class/dmi/id/product_name 2>/dev/null)" in+ MacBook8,1)+ MODULES+=(spi_pxa2xx_pci spi_pxa2xx_platform applespi)+ ;;+ MacBook9,1|MacBook10,1|MacBookPro13,[123]|MacBookPro14,[123])+ MODULES+=(intel_lpss_pci spi_pxa2xx_platform applespi)+ ;;+esacdiff --git a/os/tests/apple_boot_guest.py b/os/tests/apple_boot_guest.pynew file mode 100644index 000000000..587dd079a--- /dev/null+++ b/os/tests/apple_boot_guest.py@@ -0,0 +1,140 @@+#!/usr/bin/env python3+"""Check actual initramfs contents with private, test-only Apple DMI fixtures.++Run inside an unshared mount namespace in a disposable installed VM. This proves+module selection and dependency closure, not operation of a physical Mac keyboard.+"""+import argparse+import hashlib+import json+import os+from pathlib import Path+import shutil+import subprocess+import time++CONFIG = Path('/etc/mkinitcpio.conf.d/20-harness-apple-keyboard.conf')+FIXTURE_CONFIG = CONFIG.with_name('00-harness-test.conf')+DMI = Path('/sys/class/dmi/id/product_name')+PXA = ['spi_pxa2xx_pci', 'spi_pxa2xx_platform', 'applespi']+LPSS = ['intel_lpss_pci', 'spi_pxa2xx_platform', 'applespi']+APPLE_MODULES = set(PXA + LPSS)+++def run(*args, check=True, timeout=180, cwd=None):+ return subprocess.run(args, text=True, capture_output=True, check=check,+ timeout=timeout, cwd=cwd)+++def normalized(name):+ return name.replace('-', '_')+++def image_record(folder, name, required, forbidden):+ """Use the production preset path, then inspect its actual cpio and loaders."""+ started = time.monotonic()+ build = run('mkinitcpio', '-P', check=False)+ (folder / (name + '-build.log')).write_text(build.stdout + build.stderr)+ assert build.returncode == 0, (name, build.returncode, build.stderr)+ image = Path('/boot/initramfs-linux-lts.img')+ listing = run('lsinitcpio', '-l', str(image)).stdout+ (folder / (name + '-contents.txt')).write_text(listing)+ present = {normalized(Path(line.strip()).name.split('.ko')[0])+ for line in listing.splitlines() if '.ko' in line}+ assert set(required) <= present, (name, 'missing', set(required) - present)+ assert not set(forbidden) & present, (name, 'unexpected', set(forbidden) & present)+ extracted = folder / 'extracted'+ extracted.mkdir()+ try:+ run('lsinitcpio', '-x', str(image), cwd=extracted)+ configs = {str(path.relative_to(extracted)): path.read_text()+ for path in extracted.rglob('modules-load.d/*.conf')}+ loaded = {normalized(line.strip()) for contents in configs.values()+ for line in contents.splitlines()+ if line.strip() and not line.lstrip().startswith(('#', ';'))}+ assert set(required) <= loaded, (name, 'not explicitly loaded', set(required) - loaded, configs)+ assert not set(forbidden) & loaded+ dependencies = {}+ for module in required:+ output = run('modprobe', '--show-depends', module).stdout+ closure = {normalized(Path(line.split()[1]).name.split('.ko')[0])+ for line in output.splitlines() if line.startswith('insmod ')}+ assert closure <= present, (name, module, 'missing dependency', closure - present)+ dependencies[module] = {'modprobe': output, 'included_modules': sorted(closure)}+ finally:+ shutil.rmtree(extracted)+ with image.open('rb') as source:+ digest = hashlib.file_digest(source, 'sha256').hexdigest()+ return {'sha256': digest, 'bytes': image.stat().st_size,+ 'modules_load': configs, 'dependency_closure': dependencies,+ 'apple_modules': sorted(APPLE_MODULES & present),+ 'seconds': round(time.monotonic() - started, 3)}+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument('--candidate', type=Path, required=True)+ parser.add_argument('--output', type=Path, required=True)+ args = parser.parse_args()+ assert os.geteuid() == 0+ assert run('lsblk', '-ndo', 'SERIAL', '/dev/vda').stdout.strip() == 'HN_OS_TEST'+ assert os.readlink('/proc/self/ns/mnt') != os.readlink('/proc/1/ns/mnt'), 'Use unshare --mount'+ assert not CONFIG.exists(), 'Baseline image already contains the candidate'+ assert not FIXTURE_CONFIG.exists()+ folder = args.output.resolve()+ folder.mkdir(parents=True, exist_ok=True)+ original_dmi = DMI.read_text()+ fixture = folder / 'product_name'+ fixture.write_text('MacBookPro14,1\n')+ result = {'status': 'running', 'kernel': run('uname', '-r').stdout.strip(),+ 'mkinitcpio': run('mkinitcpio', '--version').stdout.strip(),+ 'original_dmi': original_dmi.strip(), 'selection': {}, 'images': {},+ 'scope': 'Native mkinitcpio with private DMI fixtures; no physical Apple input claim'}+ run('mount', '--bind', str(fixture), str(DMI))+ try:+ CONFIG.parent.mkdir(parents=True, exist_ok=True)+ # Isolate the missing host dependency, even if keyboard autodetection+ # correctly includes applespi on an actual Mac.+ FIXTURE_CONFIG.write_text('MODULES+=(virtio_net applespi)\n')+ result['images']['baseline'] = image_record(folder, 'baseline',+ ['virtio_net', 'applespi'], APPLE_MODULES - {'applespi'})+ FIXTURE_CONFIG.write_text('MODULES+=(virtio_net)\n')+ CONFIG.write_bytes(args.candidate.read_bytes())+ CONFIG.chmod(0o644)+ run('bash', '-n', str(CONFIG))+ expected = {'MacBook8,1': PXA, 'MacBook9,1': LPSS, 'MacBook10,1': LPSS}+ expected.update({f'MacBookPro{family},{variant}': LPSS+ for family in (13, 14) for variant in (1, 2, 3)})+ expected.update({model: [] for model in ('MacBookAir6,2', 'MacBookAir7,2',+ 'MacBookPro12,1', 'MacBookPro15,1', 'MacBookPro16,1', 'MacBookAir8,1',+ 'MacBookPro13,4', 'MacBookPro14,10', 'MacBookPro18,1', 'Standard PC', '')})+ for model, modules in expected.items():+ fixture.write_text(model + '\n')+ selected = run('bash', '-c',+ 'MODULES=(virtio_net); source "$1"; printf "%s\n" "${MODULES[@]}"',+ 'apple-selection', str(CONFIG)).stdout.splitlines()+ assert selected == ['virtio_net'] + modules, (model, selected, modules)+ result['selection'][model or '<empty>'] = selected+ for model, modules in [('MacBook8,1', PXA), ('MacBookPro14,1', LPSS)]:+ fixture.write_text(model + '\n')+ name = model.replace(',', '-')+ result['images'][model] = image_record(folder, name,+ ['virtio_net'] + modules, APPLE_MODULES - set(modules))+ # Leave only the candidate on disk and generate the ordinary PC image+ # that the host will actually boot, without any fixture modules forced.+ FIXTURE_CONFIG.unlink()+ fixture.write_text(original_dmi)+ result['images']['generic'] = image_record(folder, 'generic', [], APPLE_MODULES)+ result['candidate_sha256'] = hashlib.sha256(CONFIG.read_bytes()).hexdigest()+ result['status'] = 'passed'+ except BaseException as error:+ result.update(status='failed', error=repr(error))+ raise+ finally:+ FIXTURE_CONFIG.unlink(missing_ok=True)+ run('umount', str(DMI))+ (folder / 'guest.json').write_text(json.dumps(result, indent=2) + '\n')+++if __name__ == '__main__':+ main()diff --git a/os/tests/apple_boot_vm.py b/os/tests/apple_boot_vm.pynew file mode 100644index 000000000..61ef31f42--- /dev/null+++ b/os/tests/apple_boot_vm.py@@ -0,0 +1,110 @@+#!/usr/bin/env python3+"""Apple early-input packaging and generic encrypted-boot acceptance on native KVM."""+import argparse+import hashlib+import io+import json+import os+from pathlib import Path+import shlex+import subprocess+import tarfile+import time+from footprint_vm import copy_file+from session_vm import screen_text+from vm import VM+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument('--iso', type=Path, required=True)+ parser.add_argument('--output', type=Path, default=Path('os/test-results/apple-boot'))+ args = parser.parse_args()+ assert os.access('/dev/kvm', os.R_OK | os.W_OK), 'Native KVM is required'+ iso = args.iso.resolve()+ manifest = json.loads(iso.with_name('manifest.json').read_text())+ with iso.open('rb') as source:+ assert hashlib.file_digest(source, 'sha256').hexdigest() == manifest['iso']['sha256']+ assert iso.stat().st_size == manifest['iso']['bytes']+ folder = args.output.resolve()+ folder.mkdir(parents=True, exist_ok=True)+ root = Path(__file__).resolve().parents[1]+ candidate = root / 'root/etc/mkinitcpio.conf.d/20-harness-apple-keyboard.conf'+ vm = VM(folder, iso, 'uefi', 1024, cpu='Nehalem')+ result = {'status': 'running', 'image_sha256': manifest['iso']['sha256'],+ 'image_source': manifest['source_commit'],+ 'candidate_sha256': hashlib.sha256(candidate.read_bytes()).hexdigest(),+ 'test_source': subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip(),+ 'started_at_unix': time.time(), 'checks': []}+ config = {'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}+ try:+ vm.start(live=True)+ vm.wait(r'root@[^\r\n]*[#] ')+ 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')+ dmi_before = vm.read_file('/sys/class/dmi/id/product_name')+ copy_file(vm, candidate.read_bytes(), '/tmp/apple-candidate.conf')+ copy_file(vm, Path(__file__).with_name('apple_boot_guest.py').read_bytes(), '/tmp/apple-boot-guest.py')+ try:+ output, _ = vm.command('sudo -n unshare --mount --propagation private python3 '+ '/tmp/apple-boot-guest.py --candidate /tmp/apple-candidate.conf '+ '--output /var/tmp/harness-apple-test', timeout=600)+ (folder / 'probe.log').write_text(output)+ finally:+ vm.command('sudo -n tar -czf /tmp/apple-evidence.tar.gz -C /var/tmp/harness-apple-test '+ '--exclude=extracted . && sudo -n chmod 644 /tmp/apple-evidence.tar.gz', check=False)+ data = vm.read_file('/tmp/apple-evidence.tar.gz')+ with tarfile.open(fileobj=io.BytesIO(data)) as archive:+ archive.extractall(folder / 'native', filter='data')+ assert vm.read_file('/sys/class/dmi/id/product_name') == dmi_before, 'DMI fixture leaked'+ record = json.loads((folder / 'native/guest.json').read_text())+ assert record['status'] == 'passed', record+ assert record['candidate_sha256'] == result['candidate_sha256']+ result['checks'].append('Actual preset builds prove baseline omission and complete early-load dependency closure for both controller families')+ result['checks'].append('All nine SPI models selected; USB-only, T2, Apple Silicon and generic fixtures preserve existing modules')+ vm.command('sync')+ vm.stop()+ vm.start(live=False)+ vm.login_installed(config)+ vm.command('hn new-window -n keyboard-check ' + shlex.quote(+ 'printf "Type into Harness: "; read -r word; printf %s "$word" > /tmp/apple-terminal-word; exec sleep 600'))+ deadline = time.monotonic() + 20+ while 'type into harness' not in screen_text(vm, 'terminal-ready'):+ assert time.monotonic() < deadline+ time.sleep(.2)+ vm.type_probe('keyboard-still-works')+ vm.keys('ret')+ vm.command('timeout 10 sh -c \'until test "$(cat /tmp/apple-terminal-word 2>/dev/null)" = keyboard-still-works; do sleep .1; done\'')+ vm.screenshot('terminal-after-encrypted-reboot')+ result['checks'].append('Generic candidate initramfs boots, accepts actual graphical disk-unlock password and types into hn')+ result['status'] = 'passed'+ except BaseException as error:+ result.update(status='failed', error=repr(error))+ if vm.process and vm.process.poll() is None:+ try:+ vm.screenshot('failure')+ except Exception:+ pass+ raise+ finally:+ result['finished_at_unix'] = time.time()+ (folder / 'receipt.json').write_text(json.dumps(result, indent=2) + '\n')+ vm.stop()+ vm.log.close()+ vm.stderr.close()+ vm.control.cleanup()+++if __name__ == '__main__':+ main()diff --git a/os/tools/check.py b/os/tools/check.pyindex 786041fde..7e0c8d5b0 100644--- a/os/tools/check.py+++ b/os/tools/check.py@@ -16,6 +16,6 @@ for p in root.rglob('*'):json.loads(p.read_text())elif p.suffix == '.xml':ET.parse(p)- elif p.read_bytes().startswith((b'#!/bin/sh', b'#!/bin/bash', b'#!/usr/bin/env bash')):+ elif p.parent.name == 'mkinitcpio.conf.d' or p.read_bytes().startswith((b'#!/bin/sh', b'#!/bin/bash', b'#!/usr/bin/env bash')):subprocess.run(['bash', '-n', str(p)], check=True)print('Python, JSON, XML and shell syntax checked.')