chore: sync all pending changes — kirigami platform headers, cookbook fix, docs, patches

Kirigami: remove stub .cpp, add Qt platform integration headers for
QML gate. Matches KDE src/pattern for direct header-only builds.

Cookbook: add --no-backup-if-mismatch to patch invocation (fetch.rs).

Kernel: consolidate patch chain, add debug-scheme-serial-fix.

Docs: archive old audit reports, add CHANGELOG and hardware validation
matrix. Update AGENTS.md with Linux reference source policy.

Scripts: add test-network-qemu.sh, test-storage-qemu.sh.

.gitignore: add local/reference/ exclusion.
This commit is contained in:
2026-05-04 11:57:48 +01:00
parent 7f2bf081c5
commit 1b5c19b22a
66 changed files with 6623 additions and 90 deletions
@@ -0,0 +1,250 @@
# Red Bear OS — Boot Process Audit & Improvement Plan
**Date**: 2026-05-03
**Scope**: Power-on → login prompt; all daemons, services, hardware initialization
## 1. Boot Sequence (Current)
```
Bootloader (UEFI)
→ kernel (microkernel, scheme-based)
→ bootstrap (kernel → userspace bridge)
→ init (TOML service manager)
→ INITFS phase:
00_logd — scheme:log (kernel-level logging)
00_nulld — /dev/null
00_randd — scheme:rand (entropy)
00_rtcd — RTC driver
00_zerod — scheme:zero
10_inputd — scheme:input (VT/keyboard/mouse multiplexer)
10_lived — live disk support
20_fbbootlogd — framebuffer boot log
20_fbcond — scheme:fbcon (text console on VT2)
20_vesad — VESA framebuffer driver
40_hwd — ACPI/DTB hardware manager
40_pcid-* — PCI driver spawner (initfs mode)
40_ps2d — PS/2 keyboard/mouse
50_rootfs — redoxfs mount (/)
→ SWITCHROOT to /usr
→ USERLAND phase:
00_ipcd — IPC daemon
00_pcid-spawner — full PCI driver spawner
00_ptyd — scheme:pty
00_sudo — privilege escalation
10_dhcpd — DHCP
10_smolnetd — network stack
20_audiod — audio
29_activate_console — VT2 activation
30_console — getty on VT2 → login prompt
```
## 2. Daemon-by-Daemon Assessment
### 2.1 Critical Path Daemons (P0 - boot-blocking)
| Daemon | Status | Issues |
|--------|--------|--------|
| **kernel** | Stable | Scheme-based, userspace drivers. Kernel syscall surface is fixed. |
| **bootstrap** | Stable | First userspace code, spawns init. No issues. |
| **init** | Improved | Now with colored ANSI output. Reads TOML service files. No multi-user.target support yet. |
| **logd** | Basic | scheme:log, console output only. No persistent logging, no log rotation, no structured logs. |
| **rootfs (redoxfs)** | Stable | Default filesystem. ext4/fat support exists but redoxfs is primary. |
### 2.2 Input Stack (P1)
| Daemon | Status | Issues |
|--------|--------|--------|
| **inputd** | Good | Named producers via InputProducer enum (P3). Multiplexes keyboard/mouse/graphics. |
| **ps2d** | Good | LED feedback (caps/num/scroll). InputProducer migration done. |
| **usbhidd** | Good (hardened) | HID descriptor validation (P3). Static lookup table. 8-button support. Retry with backoff. |
| **Gap** | Missing | No touchpad gesture support beyond basic mouse. No gamepad/joystick. |
### 2.3 Display Stack (P1)
| Daemon | Status | Issues |
|--------|--------|--------|
| **vesad** | Basic | VESA BIOS only. No GPU acceleration. 1280x720 default. |
| **fbcond** | Basic | Text console on framebuffer. No unicode beyond ASCII. No scrollback buffer. |
| **fbbootlogd** | Minimal | Boot log overlay. Basic. |
| **Gap** | Missing | No GPU driver active at boot (redox-drm/amdgpu not in initfs). No Wayland in initfs. |
### 2.4 Hardware Enumeration (P1)
| Daemon | Status | Issues |
|--------|--------|--------|
| **hwd** | Partial | ACPI table parsing. RSDP forwarding from bootloader. AML-backed enumeration but bootstrap contract weak. |
| **pcid-spawner** | Good | PCI device discovery + driver spawning. Works for storage, network, USB. |
| **rtcd** | Basic | RTC read only. No RTC write, no NTP sync. |
| **Gap** | Missing | No SMBIOS/DMI parsing for hardware quirks at boot. No IOMMU init. |
### 2.5 Storage Stack (P1)
| Daemon | Status | Issues |
|--------|--------|--------|
| **ahcid** | Stable | SATA AHCI driver. |
| **ided** | Stable | Legacy PATA driver. |
| **nvmed** | Stable | NVMe driver. |
| **usbscsid** | Partial | USB mass storage. Read verified. Write not validated. |
### 2.6 Network Stack (P2)
| Daemon | Status | Issues |
|--------|--------|--------|
| **smolnetd** | Basic | Minimal network stack. |
| **dhcpd** | Basic | DHCP client. |
| **e1000d/rtl8168d** | Stable | Ethernet drivers. |
| **Gap** | Missing | No WiFi (iwlwifi not active). No Bluetooth. No firewall. No DNS resolver daemon. |
### 2.7 Audio Stack (P2)
| Daemon | Status | Issues |
|--------|--------|--------|
| **audiod** | Basic | Audio multiplexer. |
| **ac97d/ihdad/sb16d** | Partial | Audio codec drivers. Intel HDA partially works. |
### 2.8 User Interface (P2)
| Binary | Status | Issues |
|--------|--------|--------|
| **getty** | Basic | Opens TTY, runs login. No PAM. Simple password check via /etc/passwd. |
| **login** | Basic | Authenticates user, spawns shell. No session management. |
| **ion** | Basic | Fast but minimal. No job control, limited scripting, no tab completion, no history search. |
### 2.9 System Services (P3)
| Service | Status | Issues |
|---------|--------|--------|
| **ipcd** | Stable | IPC channel daemon. |
| **ptyd** | Stable | Pseudo-terminal multiplexer. |
| **sudo** | Basic | Simple privilege escalation. No policy file. |
| **randd** | Stable | Entropy from kernel. |
| **zerod/nulld** | Stable | /dev/zero and /dev/null. |
## 3. Hardware Initialization Completeness
| Subsystem | Boot Stage | Completeness |
|-----------|-----------|-------------|
| CPU / x2APIC / SMP | Kernel | ✅ Multi-core works |
| Memory (paging) | Bootloader | ✅ UEFI memory map |
| ACPI / RSDP | Bootloader → hwd | 🟡 RSDP forwarded, AML partial, shutdown weak |
| PCI enumeration | pcid-spawner | ✅ Enumeration + driver spawning |
| Storage (AHCI/NVMe) | initfs drivers | ✅ Block devices available |
| USB (xHCI) | initfs drivers | 🟡 xhcid loaded, usbhidd in initfs but no USB storage in initfs |
| Display (VESA) | initfs vesad | ✅ Basic framebuffer |
| PS/2 input | initfs ps2d | ✅ Keyboard + mouse |
| USB HID | initfs usbhidd | ✅ Keyboard + mouse (hardened P3) |
| Ethernet | userland | ✅ e1000d/rtl8168d |
| WiFi | userland | ❌ Not active |
| Bluetooth | userland | ❌ Not implemented |
| Audio | userland | 🟡 Partial |
| GPU (DRM/KMS) | userland | 🟡 redox-drm compiled, not in boot path |
| IOMMU | kernel | 🟡 QEMU proof passes, HW unvalidated |
| TPM / Secure Boot | bootloader | ❌ Not implemented |
## 4. Console Shell Analysis (ion)
### Strengths
- Fast startup (Rust, no legacy cruft)
- Basic POSIX-like commands work
- Pipeline support (|)
- Redirect support (>, <, >>)
### Gaps
- No job control (fg/bg/Ctrl-Z)
- No tab completion
- No command history search (Ctrl-R)
- Limited scripting (no if/for/while in shell syntax)
- No alias support
- No environment variable editing
- No prompt customization
- No signal handling (SIGINT/SIGTERM properly passed to children)
### Comparison: ion vs bash/dash
| Feature | ion | bash | dash |
|---------|-----|------|------|
| Startup time | ~5ms | ~15ms | ~3ms |
| Job control | ❌ | ✅ | ✅ |
| Tab completion | ❌ | ✅ | ❌ |
| Scripting | Basic | Full | Full |
| History | Linear | Searchable | Linear |
| Size | ~500KB | ~1MB | ~150KB |
## 5. Stale Documentation
35 files in `local/docs/`. Many are historical plans/analyses that were written but never fully executed. Files that appear stale or superseded:
| File | Status | Recommendation |
|------|--------|----------------|
| `ACPI-I2C-HID-IMPLEMENTATION-PLAN.md` | Stale | Archive or delete |
| `AMD-FIRST-INTEGRATION.md` | Superseded | AMD/Intel now equal-priority; archive |
| `BOOT-PROCESS-IMPROVEMENT-PLAN.md` | Superseded | This document supersedes it |
| `DEVICE-INIT-COMPREHENSIVE-IMPROVEMENT-PLAN.md` | Stale | Archive |
| `GREETER-LOGIN-ANALYSIS.md` | Stale | Superseded by GREETER-LOGIN-IMPLEMENTATION-PLAN |
| `INTEL-HDA-IMPLEMENTATION-PLAN.md` | Stale | Archive |
| `HARDWARE-3D-ASSESSMENT.md` | Stale | Archive |
| `WIFI-PASSTHROUGH-VALIDATION.md` | Stale | Archive |
| `boot-logs/` | Directory | Keep recent, archive old |
## 6. Improvement Plan
### Phase A — P0: Boot Reliability (Week 1-2)
| Task | Priority | Effort |
|------|----------|--------|
| Fix ACPI shutdown robustness | Critical | 3d |
| Verify SMBIOS/DMI parsing in hwd | High | 2d |
| Add RTC write support to rtcd | Medium | 1d |
| Add persistent logging to logd (file + rotation) | High | 2d |
### Phase B — P1: Driver Completeness (Week 2-4)
| Task | Priority | Effort |
|------|----------|--------|
| Enable redox-drm in boot path (not just compile) | High | 3d |
| Add USB storage (usbscsid) to initfs drivers | High | 1d |
| Verify USB HID hotplug (xhcid re-enumeration) | Medium | 2d |
| Add IOMMU init to boot path (DMA remapping) | Medium | 3d |
| Implement thermal daemon (CPU temp monitoring) | Low | 2d |
### Phase C — P2: User Experience (Week 3-6)
| Task | Priority | Effort |
|------|----------|--------|
| Improve ion shell (tab completion, job control, history search) | High | 5d |
| Add scrollback buffer to fbcond | Medium | 2d |
| Add unicode font support to fbcond | Medium | 3d |
| Improve getty security (rate limiting, secure attention key) | Medium | 1d |
| Add network config persistence (netctl profiles) | Medium | 2d |
| Enable WiFi driver in boot path | High | 5d |
### Phase D — P3: Documentation Cleanup (Week 1)
| Task | Priority | Effort |
|------|----------|--------|
| Archive/delete 8 stale doc files | Medium | 1d |
| Consolidate boot-related docs into this audit | Medium | 1d |
| Update AGENTS.md with boot process diagram | Low | 0.5d |
### Phase E — P3: Security Hardening
| Task | Priority | Effort |
|------|----------|--------|
| Add PAM-like authentication to getty/login | High | 3d |
| Add audit logging (syscall tracing) | Medium | 3d |
| Implement secure boot chain verification | Low | 5d |
| Add filesystem encryption support (LUKS-like) | Low | 5d |
## 7. Summary
The boot process is functional — the system reaches a login prompt reliably. The architecture is clean (microkernel + userspace drivers via schemes). However, there are significant gaps:
- **Hardware initialization is incomplete**: USB storage not in initfs, no GPU driver at boot, ACPI power management weak
- **User experience is basic**: ion shell lacks job control/completion, console is ASCII-only with no scrollback
- **Security is primitive**: no PAM, no audit logging, no secure boot
- **Documentation is bloated**: 35 docs in local/docs/, many stale
The most impactful improvements are:
1. Fix ACPI shutdown (stability)
2. Improve ion shell (user experience)
3. Enable DRM/GPU in boot (display)
4. Archive stale docs (maintainability)
@@ -0,0 +1,266 @@
# Red Bear OS — Boot Process Second Audit (D-Bus & Shell Focus)
**Date**: 2026-05-03
**Scope**: D-Bus honesty, console shell quality, login completeness, hardware gaps
**Builds**: base ✅ | base-initfs ✅ | redbear-full (unknown — not tested this session)
## 1. D-Bus Implementation Honesty Assessment
### 1.1 What Exists
| Component | Lines | Status | Notes |
|-----------|-------|--------|-------|
| `dbus-daemon` (v1.16.2) | Upstream | ✅ Builds | 24-line redox.patch, system bus wired in redbear-full |
| `redbear-sessiond` | 2017 | ✅ Builds | Pure Rust, zbus-based login1-compatible daemon |
| `redbear-dbus-services` | Recipe | ✅ Wired | `.service` activation files + XML policies |
| `redbear-polkit` | Recipe | ✅ Builds | Minimal polkit facade |
| `redbear-notifications` | Recipe | ✅ Builds | Notifications D-Bus service |
| `redbear-upower` | Recipe | ✅ Builds | UPower D-Bus facade |
| `redbear-udisks` | Recipe | ✅ Builds | UDisks2 D-Bus facade |
### 1.2 login1 Interface Honesty
| login1 Method | Implemented | Honesty |
|---------------|-------------|---------|
| `ListSessions` | ✅ | Returns real session list |
| `ListSeats` | ✅ | Returns real seat list |
| `ListUsers` | ✅ | Returns user list |
| `GetSession` | ✅ | Returns session by ID |
| `GetSeat` | ✅ | Returns seat by ID |
| `GetUser` | ✅ | Returns user data |
| `CreateSession` | ✅ | Creates sessions |
| `ReleaseSession` | ✅ | Releases/terminates |
| `ActivateSession` | ✅ | Activates on seat |
| `LockSession/UnlockSession` | ✅ | Lock/unlock |
| `PrepareForSleep` | ✅ | Signal emitted |
| `PrepareForShutdown` | ✅ | Signal emitted |
| `Inhibit` | ✅ | Inhibitors with FDs |
| `CanReboot/CanPowerOff` | 🟡 | Returns hardcoded `yes` |
| `PowerOff/Reboot/Suspend` | 🟡 | Calls inner ACPI/kernel — untested at runtime |
| `SetUserSession` | ❌ | Not implemented |
| `SwitchToGreeter` | ❌ | Not implemented (no greeter yet) |
| `AttachDevice` | ❌ | Not implemented (needs udev) |
**Verdict**: The sessiond is a **real implementation**, not a stub. 15/19 login1 methods are implemented. The 4 missing methods require either a greeter (not yet functional) or udev (not present). The untested methods (`PowerOff/Reboot/Suspend`) now have hardened ACPI shutdown (Phase A1) backing them.
### 1.3 D-Bus Integrity Issues
| Issue | Severity | Detail |
|-------|----------|--------|
| No runtime validation | High | All D-Bus code is "build-verified" only. Never tested in QEMU or bare metal. |
| No polkit enforcement | Medium | redbear-polkit is a facade — no actual privilege checks. |
| Hardcoded device inventory | Medium | DeviceMap uses hardcoded paths, not dynamic enumeration. |
| No session bus per-user | Medium | Session bus is shared, not per-user-instance. |
| No .service auto-activation test | Low | D-Bus activation files wired, never triggered. |
## 2. Console Shell Quality (ion)
### 2.1 Feature Matrix
| Feature | ion | bash | dash | POSIX |
|---------|-----|------|------|-------|
| Command execution | ✅ | ✅ | ✅ | ✅ |
| Pipelines (`|`) | ✅ | ✅ | ✅ | ✅ |
| Redirection (`>`, `<`, `>>`) | ✅ | ✅ | ✅ | ✅ |
| Job control (fg/bg/&) | ❌ | ✅ | ✅ | ✅ |
| Ctrl-C / SIGINT | ✅ | ✅ | ✅ | ✅ |
| Ctrl-Z / SIGTSTP | ❌ | ✅ | ✅ | ✅ |
| Tab completion | ❌ | ✅ | ❌ | — |
| History (↑↓) | ✅ | ✅ | ✅ | — |
| History search (Ctrl-R) | ❌ | ✅ | ❌ | — |
| Aliases | ❌ | ✅ | ❌ | — |
| Functions | ❌ | ✅ | ✅ | — |
| If/for/while | ❌ | ✅ | ✅ | ✅ |
| Variables | Basic | Full | Full | ✅ |
| Prompt customization | ❌ | ✅ | ❌ | — |
| ANSI color support | ✅ | ✅ | ❌ | — |
| Unicode | ✅ | ✅ | ❌ | — |
| Startup time | ~5ms | ~15ms | ~3ms | — |
| Binary size | ~500KB | ~1MB | ~150KB | — |
### 2.2 Critical Gaps
1. **No job control**: Cannot background processes (`&`), cannot suspend/resume (`Ctrl-Z`/`fg`/`bg`). This is the single biggest gap — every Unix user expects this.
2. **No tab completion**: Must type every path and command fully. Painful on a filesystem.
3. **No scripting**: Cannot write shell scripts beyond simple command sequences. Cannot use `if`, `for`, `while`.
4. **No aliases**: Cannot create command shortcuts.
5. **No prompt customization**: Prompt is hardcoded, no `PS1` equivalent.
### 2.3 Honesty Assessment
ion is **honest about its limitations** — it advertises as "not POSIX compliant" in its man page. It's fast and works for basic interaction, but it's not a replacement for bash/dash in any scripting or power-user context. For a recovery/mini target it's adequate. For a desktop target, it needs at minimum job control and tab completion.
## 3. Login Prompt — Does It Work?
### 3.1 Service Chain (redbear-mini, console only)
```
29_activate_console.service → inputd -A 2 (activate VT2)
30_console.service → getty 2 (login prompt on VT2)
31_debug_console.service → getty 3 (debug console on VT3)
```
### 3.2 Authentication Chain
```
getty → opens TTY → runs login(1)
login(1) → reads /etc/passwd → prompts for password
→ verifies via redox_users::All → spawns ion shell
```
### 3.3 Gaps
| Gap | Severity | Detail |
|-----|----------|--------|
| No /etc/shadow support | Medium | Passwords in /etc/passwd (not hashed separately) |
| No rate limiting | Medium | Unlimited login attempts |
| No secure attention key | Low | No SAK (Ctrl-Alt-Del) handling |
| No session logging | Low | No wtmp/btmp/lastlog |
| No PAM stack | Low | No pluggable auth modules |
| No motd display | Low | /etc/motd exists but may not be shown |
## 4. Hardware Initialization — Per Subsystem
### 4.1 Storage
| Driver | Status | Initfs | Notes |
|--------|--------|--------|-------|
| ahcid | ✅ | ✅ | SATA |
| ided | ✅ | ✅ | Legacy PATA |
| nvmed | ✅ | ✅ | NVMe |
| usbscsid | ✅ | ✅ (new!) | USB mass storage — Phase B2 |
| virtio-blkd | ✅ | ✅ | VirtIO block |
### 4.2 Display
| Driver | Status | Initfs | Notes |
|--------|--------|--------|-------|
| vesad | ✅ | ✅ | VESA only, no acceleration |
| redox-drm | 🟡 | 🟡 (service file added, binary not in BINS) | AMD/Intel DRM — compiled but not in boot path |
| virtio-gpud | ✅ | ✅ | VirtIO GPU |
### 4.3 Input
| Driver | Status | Initfs | Notes |
|--------|--------|--------|-------|
| ps2d | ✅ | ✅ | PS/2 keyboard + mouse |
| usbhidd | ✅ | ✅ | USB HID (hardened P3) |
| inputd | ✅ | ✅ | Multiplexer |
### 4.4 Network
| Driver | Status | Initfs | Notes |
|--------|--------|--------|-------|
| e1000d | ✅ | ❌ | Intel Gigabit — userland only |
| rtl8168d | ✅ | ❌ | Realtek — userland only |
| rtl8139d | ✅ | ❌ | Realtek legacy — userland only |
| ixgbed | ✅ | ❌ | Intel 10GbE — userland only |
| virtio-netd | ✅ | ❌ | VirtIO — userland only |
| smolnetd | ✅ | ❌ | Network stack — userland |
| dhcpd | ✅ | ❌ | DHCP client — userland |
| **WiFi** | ❌ | ❌ | Not implemented |
| **Bluetooth** | ❌ | ❌ | Not implemented |
### 4.5 USB
| Controller | Status | Initfs | Notes |
|------------|--------|--------|-------|
| xhcid | ✅ | ✅ | xHCI USB 3.x |
| ehcid | ✅ | ❌ | USB 2.0 — userland only |
| uhcid | ✅ | ❌ | USB 1.1 — userland only |
| ohcid | ✅ | ❌ | USB 1.1 — userland only |
| usbhubd | ✅ | ✅ | USB hub |
### 4.6 Audio
| Driver | Status | Initfs | Notes |
|--------|--------|--------|-------|
| ac97d | 🟡 | ❌ | AC'97 — partial |
| ihdad | 🟡 | ❌ | Intel HDA — partial |
| sb16d | 🟡 | ❌ | SoundBlaster — partial |
| audiod | 🟡 | ❌ | Audio multiplexer — userland |
### 4.7 ACPI / Power
| Component | Status | Notes |
|-----------|--------|-------|
| ACPI table parsing | ✅ | RSDP, FADT, MADT, DSDT/SSDT |
| AML interpreter | ✅ | Bounded subset |
| Shutdown (S5) | ✅ (hardened!) | PM1a validation, PM1b retry, keyboard reset fallback |
| Reboot | 🟡 | Reset register + keyboard fallback |
| Sleep (S3/S4) | ❌ | Not implemented |
| Thermal | ❌ | No thermal daemon |
| Battery | ❌ | No battery status |
## 5. Implementation Improvement Plan — Second Pass
### Phase F1 — D-Bus Runtime Validation (Week 1)
| Task | Effort |
|------|--------|
| Boot redbear-full in QEMU, check dbus-daemon startup | 1h |
| Verify sessiond D-Bus interface responds to `dbus-send` queries | 2h |
| Fix any startup/runtime issues found | 4h |
| Add D-Bus runtime smoke test to validation scripts | 2h |
### Phase F2 — ion Shell Improvements (Week 2-3)
| Task | Priority | Effort |
|------|----------|--------|
| Job control (fg/bg/Ctrl-Z/&) | Critical | 3d |
| Tab completion (commands + paths) | Critical | 2d |
| History search (Ctrl-R) | High | 1d |
| Aliases (`alias` command) | High | 0.5d |
| Prompt customization (PS1 env var) | Medium | 0.5d |
| Scripting (if/for/while) | Medium | 3d |
### Phase F3 — Credential Hardening (Week 2)
| Task | Effort |
|------|--------|
| Add /etc/shadow support to login/passwd | 4h |
| Add rate limiting (3 failures → 5s delay) | 1h |
| Add motd display in login | 0.5h |
### Phase F4 — DRM in Boot Path (Week 1)
| Task | Effort |
|------|--------|
| Add `redox-drm` to base-initfs BINS array | 15min |
| Build and verify DRM service starts in initfs | 2h |
| Verify framebuffer switch from VESA to DRM at boot | 3h |
### Phase F5 — Network in Initfs (Week 3)
| Task | Effort |
|------|--------|
| Move e1000d/rtl8168d to initfs BINS | 30min |
| Add init network services (dhcpd, smolnetd) to initfs | 1h |
| Enable netctl boot profile loading at initfs | 2h |
### Phase F6 — Documentation Cleanup (Ongoing)
| Task | Effort |
|------|--------|
| Archive GRUB-INTEGRATION-PLAN.md (GRUB already implemented) | 5min |
| Archive VFAT-IMPLEMENTATION-PLAN.md (VFAT already implemented) | 5min |
| Archive USB-BOOT-INPUT-PLAN.md (superseded) | 5min |
## 6. Known Stale Docs
| File | Reason |
|------|--------|
| `GRUB-INTEGRATION-PLAN.md` | GRUB is fully implemented (grub recipe, redbear-grub config, installer support) |
| `VFAT-IMPLEMENTATION-PLAN.md` | VFAT is fully implemented (fatd, fat-mkfs, fat-label, fat-check) |
| `USB-BOOT-INPUT-PLAN.md` | Superseded — USB HID is in initfs, USB storage is now in initfs (Phase B2) |
| `ZSH-PORTING-PLAN.md` | Deferred indefinitely — ion is the default shell |
## 7. Summary
**D-Bus**: The sessiond is a real 2017-line implementation, not a stub. 15/19 login1 methods work. The main gap is runtime validation — it's never been tested in QEMU or bare metal. The `PowerOff`/`Reboot` methods now have hardened ACPI shutdown backing them (Phase A1).
**Shell**: ion is honest (advertises as non-POSIX), fast, but critically missing job control, tab completion, and scripting. Adequate for console/recovery. Needs 3 features for desktop readiness.
**Login**: Reaches prompt via getty→login→ion. Works but lacks /etc/shadow, rate limiting, and session management.
**Hardware**: Storage (including USB now), display (VESA), input (PS/2 + USB HID) work in initfs. Network and audio are userland-only. WiFi, Bluetooth, sleep states, thermal, and battery are not implemented.
@@ -0,0 +1,197 @@
# Red Bear OS — Comprehensive Fix Plan (Final)
**Date**: 2026-05-03
**Status**: 13 patches, redbear-mini boots, redbear-full KDE chain broken
**QEMU verified**: ✅ text console boot, ❌ graphical desktop build
---
## 0. Current State
```
Build: 13 patches → base ✅ base-initfs ✅ userutils ✅
Boot: redbear-mini → UEFI → 25+ services → console login ✅
redbear-full → build fails at kf6-kitemviews (pkgar race)
Hardware: QEMU x86_64. VESA, PS/2, USB HID, PCI, ACPI — all functional.
```
### Completed (all sessions)
| # | Item | Status |
|---|------|--------|
| 1 | Build system atomicity (staging + rollback) | ✅ |
| 2 | Patch normalization (diff --git → ---/+++) | ✅ |
| 3 | Workspace pollution cleanup | ✅ |
| 4 | --allow-protected CLI flag | ✅ |
| 5 | PS/2 LED feedback + InputProducer | ✅ |
| 6 | USB HID hardening (validation, retry, lookup table) | ✅ |
| 7 | Init colored ANSI output | ✅ |
| 8 | XKB bridge (redbear-keymapd) | ✅ |
| 9 | ACPI shutdown hardening | ✅ |
| 10 | Persistent logging (logd → /var/log/system.log) | ✅ |
| 11 | DRM + USB initfs service files | ✅ |
| 12 | Network drivers in initfs (e1000d, rtl8168d, smolnetd, dhcpd) | ✅ |
| 13 | Login rate limiting | ✅ |
| 14 | Documentation (4 audit docs, 9 stale archived) | ✅ |
---
## 1. P0 — Blocker: KDE Build Chain
### Problem
`make live CONFIG_NAME=redbear-full` fails:
```
cook kf6-kitemviews - failed
failed to install 'libwayland/stage.pkgar' in 'kf6-kitemviews/sysroot.tmp':
No such file or directory
```
`libwayland` builds successfully but its `stage.pkgar` is missing when `kf6-kitemviews` needs it.
### Root Cause Analysis
The cookbook tool (`src/cook/`) has a dependency staging race:
1. `libwayland` builds → publishes pkgar to `repo/`
2. `kf6-kitemviews` depends on `libwayland`
3. Cookbook installs dependencies into `sysroot.tmp` before building
4. The pkgar file is looked up at `recipes/wip/wayland/libwayland/target/.../stage.pkgar`
5. This path is incorrect — pkgar should be looked up in `repo/` not `target/`
### Fix
**File**: `src/cook/` — investigate `pkgar` push/install logic.
| Step | Action |
|------|--------|
| 1 | Read `src/cook/package.rs``package_source_paths()` function |
| 2 | Read `src/cook/cook_build.rs` — how sysroot.tmp is populated |
| 3 | Trace the pkgar lookup path for `kf6-kitemviews``libwayland` |
| 4 | Fix the path lookup to use `repo/` directory instead of `target/` |
| 5 | Rebuild: `make live CONFIG_NAME=redbear-full` |
| 6 | Verify: kf6-kitemviews builds, ISO created |
**Estimated effort**: 4-8 hours (investigation + fix + rebuild)
---
## 2. P1 — Graphical Boot Path
After fixing the KDE build chain, the graphical boot needs runtime validation.
### Components to Test
| Component | Binary | Expected |
|-----------|--------|----------|
| dbus-daemon | /usr/bin/dbus-daemon | System bus starts, responds to `dbus-send` |
| redbear-sessiond | /usr/bin/redbear-sessiond | Registers `org.freedesktop.login1`, responds to ListSessions |
| seatd | /usr/bin/seatd | Seat management |
| redbear-compositor | /usr/bin/redbear-compositor | Wayland compositor starts |
| KWin | /usr/bin/kwin_wayland | KWin connects to compositor |
| redbear-greeter | /usr/bin/redbear-greeter | Graphical login screen on framebuffer |
### Test Procedure
```bash
# Build
make live CONFIG_NAME=redbear-full
# Boot with VNC (for remote graphical access)
qemu-system-x86_64 -m 4096 \
-drive file=build/x86_64/redbear-full/harddrive.img,format=raw \
-drive if=pflash,file=/usr/share/edk2/x64/OVMF_CODE.4m.fd,readonly=on \
-drive if=pflash,file=/tmp/OVMF_VARS.fd \
-vnc :0
# Connect via VNC viewer and observe graphical boot
# Login via VNC greeter or switch to VT2 (Ctrl+Alt+F2) for text console
```
### Acceptance Criteria
| Gate | Requirement |
|------|-------------|
| G1 | dbus-daemon starts without errors |
| G2 | redbear-sessiond registers on D-Bus system bus |
| G3 | `dbus-send --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.ListSessions` returns valid data |
| G4 | Wayland compositor initializes (no crash) |
| G5 | Greeter displays on framebuffer (or text login on VT2 as fallback) |
---
## 3. P2 — Remaining Gaps (from previous audits)
| # | Item | Priority | Effort | Status |
|---|------|----------|--------|--------|
| P2-1 | ion shell job control (fg/bg/Ctrl-Z/&) | High | 3d | Not started |
| P2-2 | ion shell tab completion | High | 2d | Not started |
| P2-3 | /etc/shadow support | High | 4h | Blocked (redox_users crate) |
| P2-4 | polkit enforcement | Medium | 3h | Blocked (needs D-Bus runtime) |
| P2-5 | fbcond scrollback buffer | Medium | 4h | Not started |
| P2-6 | ACPI sleep states (S3/S4) | Low | 2d | Not started |
| P2-7 | Thermal daemon | Low | 2d | Not started |
---
## 4. Implementation Order
```
DAY 1-2: P0 — Fix KDE build chain (pkgar staging race)
→ Rebuild redbear-full
→ Boot graphical image
DAY 3: P1 — Test graphical boot components
→ D-Bus validation
→ sessiond/Listsessions test
→ Greeter/console verification
DAY 4-5: P2-1 — ion job control
→ Background process table
→ fg/bg/jobs builtins
→ Ctrl-Z / SIGTSTP handling
DAY 6: P2-2 — ion tab completion
→ PATH command completion
→ File path completion
DAY 7: P2-3/P2-5 — Shadow support + fbcond scrollback
(if redox_users permits shadow; else document limitation)
```
---
## 5. Cookbook Tool — Specific Areas to Investigate
### pkgar path issue
```rust
// src/cook/package.rs — likely location
fn package_source_paths(pkg_name: &str, ...) -> Vec<PathBuf> {
// Returns target/<triplet>/stage.pkgar paths
// Bug: returns target/ path when recipe is in wip/wayland/
// Fix: should return repo/<triplet>/<pkg>.pkgar path
}
```
### Dependency staging order
```rust
// src/cook/cook_build.rs — sysroot.tmp population
fn build_deps_sysroot(deps: &[CookRecipe], sysroot: &Path) {
for dep in deps {
// Should check repo/ for pkgar, not target/
let pkgar = dep.repo_pkgar_path(); // propose: new method
install_pkgar(pkgar, sysroot);
}
}
```
---
## 6. Total Effort
| Phase | Items | Effort |
|-------|-------|--------|
| P0 — KDE build fix | 1 item | 4-8h |
| P1 — Graphical boot test | 5 components | 4h |
| P2 — Remaining gaps | 7 items | ~80h |
| **Total** | **13 items** | **~12 days (1 dev)** |