diff --git a/ROADMAP.md b/ROADMAP.md index bec4b697..5686caa3 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -18,7 +18,8 @@ M1 IN PROGRESS Emulator boot automated QEMU boot IN PROGRESS M2 PASS First native Spark boot (2026-09-24) - follow-ups: observability, console, GB10 discovery, keyboard, test rig + follow-ups: observability, console, GB10 discovery, keyboard, + test rig (design: docs/HARDWARE_TEST_RIG.md) NEXT HARD GATE: recovery media -> QEMU regression boot -> M3 kernel isolation @@ -61,7 +62,7 @@ local agent, power off, power on, and it remembers. | --- | --- | --- | --- | | M0 Reference freeze | [M0](https://github.com/aien-dev/aienos/milestone/1) | [#17](https://github.com/aien-dev/aienos/issues/17) recovery media | [#12](https://github.com/aien-dev/aienos/pull/12) Rust evidence tooling and clean snapshot ([9bd233d](https://github.com/aien-dev/aienos/commit/9bd233d)) | | M1 Emulator boot | [M1](https://github.com/aien-dev/aienos/milestone/2) | [#18](https://github.com/aien-dev/aienos/issues/18) QEMU boot, [#19](https://github.com/aien-dev/aienos/issues/19) CI | QEMU 8.2 and AAVMF chosen as the emulator | -| M2 Spark bring-up | [M2](https://github.com/aien-dev/aienos/milestone/3) | [#20](https://github.com/aien-dev/aienos/issues/20) pre-exit file, [#21](https://github.com/aien-dev/aienos/issues/21) screen evidence, [#22](https://github.com/aien-dev/aienos/issues/22) UART via SPCR, [#23](https://github.com/aien-dev/aienos/issues/23) GB10 discovery, [#24](https://github.com/aien-dev/aienos/issues/24) USB keyboard, [#25](https://github.com/aien-dev/aienos/issues/25) test rig | Gate passed: [#10](https://github.com/aien-dev/aienos/pull/10) memory handoff, [#11](https://github.com/aien-dev/aienos/pull/11) GB10 identity, [#13](https://github.com/aien-dev/aienos/pull/13) visible report ([a22b1d8](https://github.com/aien-dev/aienos/commit/a22b1d8)), [#14](https://github.com/aien-dev/aienos/pull/14) CPU topology ([44fcba7](https://github.com/aien-dev/aienos/commit/44fcba7)), [#15](https://github.com/aien-dev/aienos/pull/15) first-boot image ([52109bc](https://github.com/aien-dev/aienos/commit/52109bc)), [#16](https://github.com/aien-dev/aienos/pull/16) evidence ([f376589](https://github.com/aien-dev/aienos/commit/f376589)) | +| M2 Spark bring-up | [M2](https://github.com/aien-dev/aienos/milestone/3) | [#20](https://github.com/aien-dev/aienos/issues/20) pre-exit file, [#21](https://github.com/aien-dev/aienos/issues/21) screen evidence, [#22](https://github.com/aien-dev/aienos/issues/22) UART via SPCR, [#23](https://github.com/aien-dev/aienos/issues/23) GB10 discovery, [#24](https://github.com/aien-dev/aienos/issues/24) USB keyboard, [#25](https://github.com/aien-dev/aienos/issues/25) test rig ([design](docs/HARDWARE_TEST_RIG.md)) | Gate passed: [#10](https://github.com/aien-dev/aienos/pull/10) memory handoff, [#11](https://github.com/aien-dev/aienos/pull/11) GB10 identity, [#13](https://github.com/aien-dev/aienos/pull/13) visible report ([a22b1d8](https://github.com/aien-dev/aienos/commit/a22b1d8)), [#14](https://github.com/aien-dev/aienos/pull/14) CPU topology ([44fcba7](https://github.com/aien-dev/aienos/commit/44fcba7)), [#15](https://github.com/aien-dev/aienos/pull/15) first-boot image ([52109bc](https://github.com/aien-dev/aienos/commit/52109bc)), [#16](https://github.com/aien-dev/aienos/pull/16) evidence ([f376589](https://github.com/aien-dev/aienos/commit/f376589)) | | M3 Kernel isolation | [M3](https://github.com/aien-dev/aienos/milestone/4) | [#26](https://github.com/aien-dev/aienos/issues/26) vectors, [#27](https://github.com/aien-dev/aienos/issues/27) MMU, [#28](https://github.com/aien-dev/aienos/issues/28) timer and GIC, [#29](https://github.com/aien-dev/aienos/issues/29) topology-aware scheduler, [#30](https://github.com/aien-dev/aienos/issues/30) IPC and capabilities | Frame allocator, bounded UART, fault capture used on the first boot | | M4 Storage and recovery | [M4](https://github.com/aien-dev/aienos/milestone/5) | [#31](https://github.com/aien-dev/aienos/issues/31) NVMe and System Store | Host-tested store and WAL recovery | | M5 Encryption and identity | [M5](https://github.com/aien-dev/aienos/milestone/6) | [#32](https://github.com/aien-dev/aienos/issues/32) | Host-tested agent identity (ADR 0007) | diff --git a/docs/HARDWARE_TEST_RIG.md b/docs/HARDWARE_TEST_RIG.md new file mode 100644 index 00000000..64192b29 --- /dev/null +++ b/docs/HARDWARE_TEST_RIG.md @@ -0,0 +1,194 @@ +# Machine 1 hardware test rig + +**Status: proposed design (2026-09-24). Nothing is wired or enabled yet. The +operator chooses and approves the parts; maintainers wire it up. Until then, +M2C power, capture and input stay pending and boots stay attended.** + +Governing: [ADR 0011](adr/0011-machine-1-hardware-test-rig.md), +[MILESTONES.md gate M2C](MILESTONES.md), [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md), +issue [#25](https://github.com/aien-dev/aienos/issues/25). + +## Why + +Every Spark boot currently needs a person at the machine: someone holds the +power button when a boot hangs, photographs the screen because the post-exit +report has no other record, and types at the firmware menus. That does not +scale, and it cannot run unattended. The rig gives three **independent** +functions for Machine 1, all serialized through +`aien-proof hold --resource machine-1` (see +[Serialization](#serialization-through-aien-proof)): + +1. **Power and reset control**: momentary press, long press (force off), + and a hard power cut that always works. +2. **Display or console capture**: the screen from cold boot through the + post-exit report, replacing the operator photograph. +3. **Deterministic input and boot selection**: scripted keystrokes into the + firmware boot menu, the firmware setup screen, and later the AIENOS early + console, so the same image boot can be driven the same way every time. + +Independence matters: a hung capture dongle must not block a power cut, and a +dead HID gadget must not trap the machine with no way to reboot it. Each +function below fails without breaking the other two. + +A Raspberry Pi is already cabled to the Spark and acts as the rig controller: +USB keyboard gadget, capture host, relay driver, and the place `aien-proof` +runs. + +## Parts list + +Prices are approximate, one unit each, 2026. Nothing here is proprietary; every +part is replaceable with an equivalent. + +| Function | Part | Role | Approx. cost | +| --- | --- | --- | --- | +| Controller | Raspberry Pi 5 (already cabled to the Spark) | Runs `aien-proof`, the gadget stack, capture and relay control | owned | +| Power sense | Spark ATX 24-pin sense lead (`PWR_OK`, green wire `PS_ON`) tapped at the PSU connector | Ground `PS_ON` to force the PSU on; read `PWR_OK` to know the board has power | cable only | +| Power cut | SPDT relay board, 5 V coil, 10 A mains-rated contacts (for example an opto-isolated Songle SRD-05VDC module) | Inline with the mains feed or the PSU enable; drops power unconditionally | ~5 USD | +| Power/reset buttons | 2x reed or opto-isolated reed relays (for example Omron G3VM SIP MOSFET relays) | One across the Spark front-panel power-header pins, one across the reset-header pins; momentary closure only | ~4 USD | +| Display capture | USB 3 HDMI capture dongle, UVC class, 1080p60 (for example an MS2109 or MS2130 based dongle) | Spark HDMI out to dongle input; appears as a webcam on the Pi; loop-through port passes the desk monitor | ~20 to 40 USD | +| Input emulation | The Pi itself, USB OTG port in HID gadget mode (Linux `configfs`, `dwc2` overlay) | Presents a standard USB boot-protocol keyboard to the Spark | included | +| Console capture | Pi GPIO UART (TX/RX) wired to the Spark UART at `0x16A00000` | Bounded serial console once [#22](https://github.com/aien-dev/aienos/issues/22) lands; 3.3 V levels only | jumper wires | +| Enclosure and safety | Fused mains inlet box for the relay, insulated standoffs, labeled header leads | Mains stays in a closed, fused box; low voltage leaves it | ~20 USD | + +Total new spend is roughly 50 to 70 USD. No part is on the Spark's boot +critical path except by explicit command: with every relay at rest and every +cable disconnected, the Spark boots exactly as it does today. + +## Function 1: power and reset control + +The Spark exposes standard PC-style front-panel pins. Shorting the power pins +briefly is a press; shorting them for about five seconds forces power off. The +relay board gives a hard cut that works even when the board is wedged. + +- `power.press` and `reset.press`: close the matching reed relay for about + 500 ms, then open. Reed relays are used for the button lines because they are + isolated, polarity-tolerant and cannot drive the header. +- `power.forceoff`: hold the power relay closed for 5 s. +- `power.cut` / `power.restore`: energize or release the mains relay. This is + the last resort and the recovery path for every wedged state. +- `power.status`: read the PSU `PWR_OK` sense line, so a script can wait for + power-good instead of sleeping a fixed time. + +Safety invariants (enforced by the control scripts, reviewed in the ledger): + +- The mains relay is **fail-on**: power flows when the relay is at rest, so a + dead Pi or a crashed script never holds the machine dark. +- The button relays are **momentary-only**: the driver enforces a maximum + closure time in software and the hardware timer on the relay board enforces + it if the Pi hangs. +- `power.cut` is the only destructive action, and it is always available to + the operator and to a failing script. + +## Function 2: display and console capture + +Two capture paths, both terminating on the Pi: + +- **HDMI**: the Spark's display output goes through the capture dongle's + loop-through port to the desk monitor, and the dongle's USB side lands on + the Pi as a UVC webcam. A capture run records video from before power-on + until the machine is back in Linux, plus a still frame at each stage gate + (firmware logo, pre-exit report, post-exit report, countdown). This replaces + the "photograph the screen" step in + [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md) and records the post-exit + drawing that the M2 evidence + ([evidence/m2_first_boot_2026-09-24.md](../evidence/m2_first_boot_2026-09-24.md)) + lists as a gap. +- **UART**: the kernel already has a bounded 16550-style UART writer at + `0x16A00000`, 921600 baud (`crates/aienos-kernel/src/arch/aarch64.rs`), + skipped on the first boot because GB10 discovery failed. Once [#22](https://github.com/aien-dev/aienos/issues/22) + (SPCR-based discovery) lands, the Pi's GPIO UART records it at 3.3 V + levels. Until then, HDMI capture is the only post-exit record and stays + mandatory. + +Capture is read-only: nothing in this function can change what the machine +does. A failed capture never blocks power control. + +## Function 3: deterministic input and boot selection + +The Pi's OTG port runs the Linux HID gadget (`configfs` + `dwc2`) and appears +to the Spark as a plain USB keyboard. The gadget implements the HID boot +protocol, so it works in the firmware setup screen and boot menu where no OS +driver exists, and later against the native xHCI/HID driver from +[#24](https://github.com/aien-dev/aienos/issues/24). + +Boot selection is deterministic: the rig never types blind. Each scripted +sequence is a list of (wait for capture frame matching X, send keystrokes Y) +steps. Examples: + +- Boot menu: `power.press`, wait for the firmware logo frame, send `Esc`, + wait for the boot-menu frame, send the arrow-key count for the `ubuntu` + entry, send `Enter`. +- Firmware setup: the documented `systemctl reboot --firmware-setup` path is + preferred; the gadget is the fallback when Linux is not running. +- AIENOS console: once the early console takes keyboard input, sequences come + from the same runner. + +The keystroke sets, frame references and expected end states are versioned in +this repository next to the scripts that use them, so a boot sequence maps to +one exact commit, same rule as the staged image. + +## Serialization through `aien-proof` + +`aien-proof` and its `machine-1` resource lock live in the +[aien-sovereign-core](https://github.com/aien-dev/aien-sovereign-core) +repository; this repository holds the rig design and the contract the control +surface must meet. The contract is the one already used for staging: + +```text +aien-proof hold --resource machine-1 --job -- +``` + +Rules: + +- Every rig function, including capture, runs only inside a + `machine-1` hold. The hold's full output becomes the ledger event, exactly + as `stage_one_time_boot.sh` and `collect_boot_report.sh` already work. +- A hold runs one rig command. The rig never acts outside a hold; an attended + boot by the operator is recorded as one too. +- `power.cut` is the single exception reachable in an emergency and is still + wrapped by the hold when scripted; physically, the operator can always cut + power by hand. +- Scripts that run under the hold get no stdin, so anything privileged is + pre-authorized (`sudo -v`) before the hold, as in + [NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md). + +The M2 evidence flow changes in one place: the photograph rows +(`framebuffer:` line and post-exit drawing) come from capture stills named in +the ledger payload, and the collector checks them the way it checks the +firmware-variable report today. + +## Attended-to-unattended boot contract + +The current attended procedure ([NATIVE_BOOT_ONE_TIME.md](NATIVE_BOOT_ONE_TIME.md)) +maps onto the rig without changing the image: + +| Attended step today | With the rig | +| --- | --- | +| Operator holds power button after a hang | `power.forceoff`, then `power.press` | +| Monitor attached; operator photographs the screen | HDMI capture stills and video, recorded in the ledger payload | +| Keyboard attached; operator picks entries in firmware | HID gadget sequences, matched against capture frames | +| Recovery USB stick chosen from the boot menu by hand | Boot-menu sequence against the same capture frames | + +Until the owner-controlled boot chain exists (see the Secure Boot note in +[MILESTONES.md](MILESTONES.md)), the rig changes how boots are driven, not +what is booted: Secure Boot stays on, native AIENOS boots stay paused, and the +rig's first job is running attended flows like recovery-media testing and the +TRUST-1 100-boot campaign without a person in front of the machine. + +## Wiring checklist (maintainers) + +1. Bench-test the relay board on a lamp before touching the Spark. +2. Tap `PS_ON`/`PWR_OK` at the ATX connector; verify sense reads on the Pi. +3. Identify the Spark front-panel header; wire the two reed relays; verify a + 500 ms closure powers the machine on and off. +4. Route HDMI through the capture dongle to the desk monitor; verify the Pi + sees a UVC device and a frame. +5. Enable the HID gadget on the Pi OTG port; verify the Spark firmware sees a + keyboard (boot-menu navigation by script). +6. Wire the UART (3.3 V only); leave it disconnected until [#22](https://github.com/aien-dev/aienos/issues/22) + makes the Spark side real. +7. Run the attended procedure once under the rig, end to end, and record the + ledger events as the rig's commissioning evidence. + +Each step is independently verifiable and independently reversible; a step +that fails leaves the previous functions working. diff --git a/docs/MILESTONES.md b/docs/MILESTONES.md index 912d25ee..0e62cf9d 100644 --- a/docs/MILESTONES.md +++ b/docs/MILESTONES.md @@ -45,7 +45,7 @@ only at M8. Status words: **done** = verified on this repository's evidence; | | UART at `0x16A00000` (bounded, Spark only) | built, not attempted | PR #13; skipped on the first boot because GB10 discovery failed | | | USB keyboard (xHCI + HID) | pending | | | **M2C** Hardware test automation | Exclusive Machine 1 key and ledger records in `aien-proof` | done on hardware | aien-sovereign-core PR #126; first boot staged and collected under `machine-1` (ledger events 83 to 85) | -| | Power/reset control, HDMI capture, USB input emulation | pending | Needs hardware chosen by the operator | +| | Power/reset control, HDMI capture, USB input emulation | design proposed, wiring pending | [HARDWARE_TEST_RIG.md](HARDWARE_TEST_RIG.md) and [ADR 0011](adr/0011-machine-1-hardware-test-rig.md); Raspberry Pi controller, parts chosen, operator approval and wiring pending | | **M3** Kernel isolation | MMU, exceptions, interrupts, timer, scheduler, IPC/capabilities | pending | Scheduler consumes M2A CPU topology | | **M4** Storage and recovery | | pending | Host crates exist (`recovery`, `store`) | | **M5** Encryption and identity | | pending | | @@ -98,7 +98,7 @@ evidence that it did so, and returns to the existing system without damaging it. `scripts/collect_boot_report.sh` prints `M2_GATE: PASS` only when all of those checks hold. -**Result 2026-09-24: `M2_GATE: PASS`** on the first attended boot ([evidence](../evidence/m2_first_boot_2026-09-24.md)). Open items: GB10 discovery before firmware exit, the pre-exit report file, recording post-exit screen drawing, UART output, and bootable recovery media. +**Result 2026-09-24: `M2_GATE: PASS`** on the first attended boot ([evidence](../evidence/m2_first_boot_2026-09-24.md)). Open items: GB10 discovery before firmware exit, the pre-exit report file, recording post-exit screen drawing (covered by rig HDMI capture once wired, see [HARDWARE_TEST_RIG.md](HARDWARE_TEST_RIG.md)), UART output, and bootable recovery media. --- diff --git a/docs/adr/0011-machine-1-hardware-test-rig.md b/docs/adr/0011-machine-1-hardware-test-rig.md new file mode 100644 index 00000000..d7d2de9b --- /dev/null +++ b/docs/adr/0011-machine-1-hardware-test-rig.md @@ -0,0 +1,77 @@ +# ADR 0011: Machine 1 Hardware Test Rig (Power, Capture, Input) + +Status: proposed, 2026-09-24. Requires operator approval of the parts list +before maintainers wire anything. It does not change the boot architecture. +Governing: [MILESTONES.md gate M2C](../MILESTONES.md), +[HARDWARE_TEST_RIG.md](../HARDWARE_TEST_RIG.md), +[NATIVE_BOOT_ONE_TIME.md](../NATIVE_BOOT_ONE_TIME.md), +issue [#25](https://github.com/aien-dev/aienos/issues/25). + +## Context + +Every Spark boot needs a person at the machine: power and reset by hand, +screen evidence by photograph, and firmware interaction by keyboard. Gate M2C +requires power/reset control, HDMI capture and USB input emulation before +hardware testing can run unattended or at any cadence. A Raspberry Pi is +already cabled to the Spark and can host all three functions. + +## Decision + +Build the Machine 1 test rig as three **independent** functions on the +existing Raspberry Pi controller, with the parts list and wiring in +[HARDWARE_TEST_RIG.md](../HARDWARE_TEST_RIG.md): + +1. **Power and reset control**: reed relays across the front-panel power and + reset pins, a fail-on mains relay for hard power cut, and a `PWR_OK` sense + line for power state. +2. **Display and console capture**: a UVC HDMI capture dongle with + loop-through on the Spark's display output, and the Pi GPIO UART for the + Spark console once SPCR-based UART discovery + ([#22](https://github.com/aien-dev/aienos/issues/22)) exists. +3. **Deterministic input and boot selection**: the Pi USB OTG port as an HID + boot-protocol keyboard gadget, driven by scripted, capture-verified + keystroke sequences. + +All three functions are serialized through +`aien-proof hold --resource machine-1`, whose implementation and ledger live +in the [aien-sovereign-core](https://github.com/aien-dev/aien-sovereign-core) +repository. This repository holds the design, the operating contract and the +versioned boot sequences. + +## Invariants + +1. **Independence.** Each function fails without breaking the other two. A + failed capture never blocks power control; a dead keyboard gadget never + traps the machine. +2. **Fail-on power.** The mains relay passes power at rest, so a dead or hung + controller cannot hold the machine dark. The operator can always cut power + by hand. +3. **Momentary-only buttons.** Button relays close only for bounded intervals, + enforced in software and by the relay hardware. +4. **Read-only capture.** Capture observes; it never alters the machine. +5. **Serialized control.** Every rig function runs only inside an + `aien-proof hold --resource machine-1`; the hold output is the ledger + event. Deterministic sequences are versioned in this repository so a boot + maps to one exact commit, same rule as the staged image. +6. **No trust change.** The rig drives boots; it does not change what boots. + Secure Boot stays on and native AIENOS boots stay paused until the + owner-controlled boot chain exists. The rig adds no credentials, network + services or privileged host state to the trusted base. +7. **Off the critical path at rest.** With every relay at rest the Spark + behaves exactly as it does unwired. + +## Consequences + +- Screen evidence for boots stops depending on an operator photograph; the + post-exit drawing gap in the M2 evidence becomes a capture artifact named + in the ledger payload. +- Recovery-media testing + ([#17](https://github.com/aien-dev/aienos/issues/17)) and the TRUST-1 + 100-boot campaign can run without a person at the machine. +- The HID gadget becomes the hardware test target for the native xHCI/HID + keyboard driver ([#24](https://github.com/aien-dev/aienos/issues/24)). +- `aien-proof` gains rig commands under the existing `machine-1` resource + lock; that work lands in aien-sovereign-core, not here. +- The rig is removed piece by piece only if a native path replaces it (for + example native network control after M6); the capture and input functions + are expected to stay through the M8 demonstration. diff --git a/docs/adr/README.md b/docs/adr/README.md index 77302362..b0677e2b 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -16,6 +16,7 @@ This directory documents the key architectural decisions and formal technical sp | [ADR 0008](0008-temporary-bring-up-firmware-report-exception.md) | Temporary bring-up exception: post-handoff firmware report (trigger 11) | Accepted (temporary) | 2026-09-24 | [ADR 0003](0003-bootstrap-firmware-handoff-and-minimal-object-store.md); [`MILESTONES.md` section 0](../MILESTONES.md); [`NATIVE_BOOT_ONE_TIME.md`](../NATIVE_BOOT_ONE_TIME.md) | | [ADR 0009](0009-el2-bootstrap-to-el1h-kernel-transition.md) | Two-Stage Exception Level Architecture (EL2 Bootstrap to EL1h Kernel) | Accepted | 2026-09-24 | [`ARCHITECTURE.md` §3, §6](../ARCHITECTURE.md); [`BLUEPRINT.md` §8, §15](../BLUEPRINT.md); [`MILESTONES.md` Phase 2, 3](../MILESTONES.md) | | [ADR 0010](0010-fabric-machine-identity-and-capability-advertisement.md) | Fabric Machine Identity and Capability Advertisement | Proposed (post-M6) | 2026-09-24 | [`ARCHITECTURE.md` §2](../ARCHITECTURE.md); [`BLUEPRINT.md` §21, §25, §26](../BLUEPRINT.md); [`MILESTONES.md` Phase 8](../MILESTONES.md); [ADR 0004](0004-reversibility-definition-and-network-effect-boundary.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [issue #37](https://github.com/aien-dev/aienos/issues/37) | +| [ADR 0011](0011-machine-1-hardware-test-rig.md) | Machine 1 Hardware Test Rig (Power, Capture, Input) | Proposed | 2026-09-24 | [`MILESTONES.md` section 0, gate M2C](../MILESTONES.md); [`HARDWARE_TEST_RIG.md`](../HARDWARE_TEST_RIG.md); [`NATIVE_BOOT_ONE_TIME.md`](../NATIVE_BOOT_ONE_TIME.md) | | [ADR 0012](0012-self-construction-capability-growth-and-generations.md) | Self-Construction, Capability Growth, and Reversible System Generations | Accepted | 2026-09-24 | [ADR 0002](0002-incumbent-os-as-migration-environment.md); [ADR 0006](0006-deterministic-recovery-core-and-offline-operator-authority.md); [ADR 0007](0007-continuous-existence-provisioning-once.md); [`ROADMAP.md`](../../ROADMAP.md) (SEED-0A, SEED-0B) | ---