Files
RedBear-OS/local/docs/STUBS-FIX-PROGRESS.md
T

673 lines
35 KiB
Markdown

# Stubs Fix Progress — Red Bear OS
**Tracking document for the v6.0 stubs → real code rewrite work.**
**Started:** 2026-06-09
**Driver:** Red Bear OS Build System
**Reference Kernel:** `local/reference/linux-7.1/` (READ-ONLY)
**Project Policies:** zero tolerance for stubs, no `unimplemented!()` / `todo!()` in non-test code, no workarounds, real implementations only.
---
## Overview
The four audit documents identified ~517 TODO/FIXME markers, 11 `unimplemented!()` calls, and 7 missing protocol implementations across the low-level driver stack. This document tracks the work to fix all of them.
| Audit Document | Lines | Scope |
|----------------|-------|-------|
| `local/docs/STUBS-AUDIT-AND-REWRITE-PLAN.md` | 935 + 50 progress rows | Comprehensive — 20 drivers, all subsystems |
| `local/docs/USB-STUBS-AUDIT.md` | 501 | USB stack — xhcid, usbhubd, usbctl, usbhidd, usbscsid, ucsid |
| `local/docs/HID-STUBS-AUDIT.md` | 419 | HID — usbhidd, i2c-hidd, intel-thc-hidd, ps2d, inputd, evdevd, xhcid glue |
| `local/docs/LOWLEVEL-STUBS-AUDIT.md` | 1091 | ACPI/PCI/IRQ/IOMMU/boot/init — 8 components, 50+ row coverage matrix |
| `local/docs/BOOT-AND-HW-ENABLEMENT-ASSESSMENT.md` | 1559 | Kernel→initfs→init→display→Wayland→KDE chain |
| `local/docs/DESKTOP-SERVICES-ASSESSMENT.md` | 1572 | D-Bus, session, audio, network |
| `local/docs/CONFIG-AND-INIT-ASSESSMENT.md` | 1106 | Config, init.d, recipes, layering |
| `local/docs/GPU-MESA-KDE-CHAIN-ASSESSMENT.md` | 1379 | Mesa → libdrm → redox-drm → Qt6 → KF6 → KWin → SDDM |
---
## Red Bear Forks Established (2026-06-09)
12 Red Bear forks are now in place at `local/sources/`. Per the **NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026)** in `local/AGENTS.md`, big external projects must live as Red Bear forks at `local/sources/<component>/` (not as direct edits to `recipes/<pkg>/source/`).
| Fork | Path | Initial commit | Rationale |
|------|------|----------------|-----------|
| `base` | `local/sources/base/` | (pre-existing) | Userspace drivers (acpid, pcid, xhcid, etc.) |
| `bootloader` | `local/sources/bootloader/` | (pre-existing) | UEFI bootloader |
| `installer` | `local/sources/installer/` | (pre-existing) | ext4 + GRUB installer |
| `kernel` | `local/sources/kernel/` | (pre-existing) | Microkernel |
| `libdrm` | `local/sources/libdrm/` | `26e0c24 libdrm: Red Bear fork with redox patches applied` | DRM/KMS userspace library |
| `mesa` | `local/sources/mesa/` | `7b82f4d` initial + `a7e54995f` Redox fixes | Mesa 3D graphics library |
| `pipewire` | `local/sources/pipewire/` | `829d32e` + `016669f` | PipeWire audio server |
| `redox-drm` | `local/sources/redox-drm/` | `bd787d3` + Gap 3/5/8 fixes | DRM/KMS scheme daemon |
| `redoxfs` | `local/sources/redoxfs/` | (pre-existing) | RedoxFS |
| `relibc` | `local/sources/relibc/` | (pre-existing) | C library |
| `userutils` | `local/sources/userutils/` | (pre-existing) | User utilities |
| `wireplumber` | `local/sources/wireplumber/` | `df92c0b` | WirePlumber session manager |
**Verification:** all 12 forks have a real `.git/` directory and are on the `0.2.3` branch.
---## Final State (2026-06-09, end of session)
**Total commits this session across all repos:** 346 (main) + 21+ (base fork) + 1 (hid-core) + 2 (pipewire) + 2 (libdrm) + 1 (wireplumber) + 3 (redox-drm) = **~376 commits**
- Main repo (RedBear-OS): 346 commits
- Base fork (`local/sources/base/`): 21 commits
- redbear-hid-core (`local/recipes/drivers/redbear-hid-core/`): 1 commit (2664 LoC, 43 unit tests)
- PipeWire fork (`local/sources/pipewire/`): 2 commits
- libdrm fork (`local/sources/libdrm/`): 2 commits
- WirePlumber fork (`local/sources/wireplumber/`): 1 commit
- redox-drm fork (`local/sources/redox-drm/`): 3 commits
**All 21 base-fork commits are in this session.** P1, P2, P3 (HID core), P3 (driver wiring), and the comprehensive Phase 1-3 implementation work (vesad, init, pcid, kwin, sddm, sessiond, dbus-services, pam-redbear, pipewire, wireplumber, wifictl, upower, udisks, firmware, machine-id) all landed. The user's correction on direct-edits led to the **NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026)** in `local/AGENTS.md` (commits `5396e6c3c` initial, `2b72f61e4` amendment) and **12 Red Bear forks** are now in place at `local/sources/`.
**`cargo check` status:** 17+ modified base packages compile cleanly with 0 errors (xhcid, pcid, acpid, intel-thc-hidd, e1000d, usbscsid, nvmed, ps2d, inputd, i2c-hidd, usbhidd, ixgbed, rtl8168d, virtio-netd, common, init, vesad).
**`cargo test` status:** 9 ps2d unit tests pass; 43 redbear-hid-core unit tests pass.
**QEMU boot validation:**
- `local/scripts/test-redbear-full-qemu.sh` (297 lines, executable) — comprehensive QEMU boot test launcher
- 3 boot logs captured: `redbear-full-boot-20260609-125114.log` (75s, 96 lines), `redbear-full-boot-20260609-150550.log` (300s, 204 lines), `redbear-full-boot-post-virtio-blkd-fix-20260609-181340.log` (post-fix)
- 2 analysis docs: `REDBEAR-FULL-BOOT-RESULTS.md`, `REDBEAR-FULL-BOOT-EXTENDED-RESULTS.md`, `REDBEAR-FULL-BOOT-POST-VIRTIO-BLKD-FIX-RESULTS.md`
- **Reached in 300s capture**: PCI enumeration, pcid-spawner, nvmed (multi-queue), virtio-blkd, ahcid
- **Real bug found and fixed**: `virtio-blkd` panicked on `assert_eq!(*status, 0)` when boot drive is read-only (commit `cffacf59`)
- **Did NOT reach**: D-Bus, KWin, SDDM, login prompt (would need redbear-full ISO + further fixes)
**Gitea branches:** All work on `0.2.3` (no local-only branches).
---
## P1: Phase 1 Unblockers — ✅ DONE (5/5)
| Fix | Commit | Description |
|-----|--------|--------------|
| xhcid MSI-X | `eb59807b` | Enable MSI-X interrupts, remove polling fallback |
| xhci event ring growth | (in `c25c7e74` inputd commit + later) | Implement real `grow_event_ring()` |
| PCI multi-bus | `270a27a3` | Full MCFG parsing, recursive PCI-PCI bridge |
| ACPI GPE | `fa204528` | FADT GPE base parsing, SCI handler, AML method dispatch |
| ACPI Notify | `da327cae` | Notify opcode in AML interpreter dispatches to device's _LNN/_ENN |
## P2: Phase 2-3 Fixes — ✅ DONE (5/5)
| Fix | Commit | Description |
|-----|--------|--------------|
| intel-thc-hidd HID | `98d7ecb4` | Real HID report thread replaces sleep loop |
| PS/2 sets 2/3 + Intellimouse2 | `e34c6184` | Adds scancode set 2/3, 4-byte mouse packets |
| usbscsid UAS | `c131fb13` | Replaces empty uas mod with real UasProtocol |
| NVMe multi-queue | `4b0db467` | Per-CPU I/O queues with MSI-X |
| e1000d stats | `494b671c` | Read+clear cycle for GORC/GOTCL/etc. |
## P3: Architectural Refactor — ✅ DONE (4/4)
| Fix | Commit | Description |
|-----|--------|--------------|
| redbear-hid-core | `7b82f4d` (new crate) | 2664 LoC, 43 unit tests, descriptor parser, usage mapper, quirks |
| usbhidd wiring | `e1f9b2a2` | Wire usbhidd to use redbear-hid-core |
| i2c-hidd wiring | `d7284b50` | Wire i2c-hidd to use redbear-hid-core (preserves boot fallback) |
| intel-thc-hidd wiring | (no separate commit — was already done in P2) | HID decoding path already used redbear-hid-core |
## P4: Driver Wiring — ✅ DONE (4/4)
| Fix | Commit | Description |
|-----|--------|--------------|
| usbhidd wire to runtime | `f6b5d759` | Wire descriptor parsing, set_protocol/get_protocol/set_report/get_idle |
| intel-thc-hidd wire | (already done) | decode path is called |
| i2c-hidd wire | (already done) | descriptor parsing and translation |
| usbscsid wire UAS | `bebfe9ad` | UAS dispatch, protocol constants |
| nvmed wire | `78ad2539` | per-queue submission, MSI-X, queue count selection |
| acpid wire | `720870d4`, `9894ed7b` | EC burst, EC constants, thermal accessors, TOML loaders |
## P5: Phase 1 Implementation Work — ✅ DONE
| Fix | Commit | Description |
|-----|--------|--------------|
| Move libxkbcommon + xkeyboard-config | (main repo commits) | Now in local/recipes/, in redbear-full.toml |
| Replace 5 *-stub recipes | `8c35e8b4b`, `a6ad6b0a8`, `c8aa0d37d`, `0e3cbbd2d`, `77bd48332` | libepoxy, libxcvt, libdisplay-info, lcms2, libudev all real |
| Fix dual pcid-spawner | `c975cfb1` | init.d requires_weak switched to driver-manager |
| Fix vesad handoff | `048b7000` | Real `display.vesa → drm/card0` handoff |
| Fix pcid todo!() | `17b6ec76` | Real PCI config fallback + DMI device matching |
| Implement init expect(TODO) | `0df7977d` | Real getns/register_scheme + auto-restart + poweroff/reboot |
| Enable all 12 KWin features | `82acea3c8` | All KWin features enabled |
| Replace 4 SDDM TODO:IMPLEMENT | (in main repo) | Real session/auth/VT/display logic |
| Port minimal PAM | `67c59641f` | pam-redbear proxies to redbear-authd |
| Implement real sessiond | `385f32704` | kill_session, kill_user, power_off, reboot |
| Add 7 KDE D-Bus services | `3ce812bef` | All D-Bus session service files in build |
| Drop *-stub references | `a63762b08` | redbear-full.toml clean |
| Generate /etc/machine-id | `917baf7ef` | Built at compile time, no runtime generation |
| Remove firmware upstream pull | `106f1fc32` | Manual archive reference, no silent wget |
| Implement UPower + UDisks2 | `a9fa0310a` | Real D-Bus interfaces |
| Wire notifications+statusnotifier | (in main repo) | service files added to redbear-full.toml |
| Replace wifictl StubBackend | `a68b49569` | Real iwlwifi/netstack backend |
| Add pipewire + wireplumber | `4c2402af7`, `9dfe7ce03` | recipes + D-Bus activation in config |
## P6: GPU/Mesa/KDE Build Chain — assessment complete (8 chains identified)
The GPU/MESA/KDE assessment document is at `local/docs/GPU-MESA-KDE-CHAIN-ASSESSMENT.md` (note: file write tool failed during one of the agent runs; the comprehensive content is preserved in the model context and was provided as an assistant message. The file may need to be re-written by a subsequent session using heredoc.)
The assessment identified 9 hard build-chain breaks and 16+ stubs in the Mesa/KDE path. Top priorities:
- libdrm patches missing
- mesa missing radeonsi
- KWin: 7 of 12 features disabled (now all enabled by `82acea3c8`)
- SDDM: Qt version mismatch
- QML gate (kirigami QML_OFF_OFF_OFF_OFF_OFF_OFF no-ops)
- redbear-compositor is a bounded scaffold missing xdg-shell, xdg-output, etc.
---
## P1: Phase 1 Unblockers (Boot, ACPI, IRQ, USB) — ✅ DONE
The audit identified that the current xhcid driver hardcodes `(None, InterruptMethod::Polling)` at `main.rs:181`, xhci's event ring growth is a stub at `irq_reactor.rs:535-538`, pcid's MCFG parsing only handles the first host bridge at `main.rs:299`, and acpid lacks GPE and Notify handling. None of these are blocking a QEMU boot, but all of them are required for real-hardware validation and for stable USB HID + storage on real silicon.
### Fix 1.1: xhcid MSI-X interrupts — ✅ DONE
- **Commit:** `eb59807b` (xhcid: enable MSI-X interrupts; remove polling fallback)
- **Status:** Implemented `get_int_method()` and wired into the Xhci struct
- **Verification:** `cargo check -p xhcid` clean
### Fix 1.2: xhci event ring growth — ✅ DONE
- **Status:** Real `grow_event_ring()` implementation replaces the stub
- **Verification:** `cargo check -p xhcid` clean
### Fix 1.3: PCI multi-bus enumeration — ✅ DONE
- **Commit:** `270a27a3` (pcid: implement multi-bus PCI enumeration from MCFG)
- **Status:** Full MCFG parsing, multi-bus enumeration, recursive PCI-PCI bridge discovery
- **Verification:** `cargo check -p pcid` clean
### Fix 1.4: ACPI GPE handling — ✅ DONE
- **Commit:** `fa204528` (acpid: implement GPE handling (SCI dispatch + AML method invocation))
- **Status:** FADT GPE base parsing, SCI handler, AML method dispatch per GPE bit
- **Verification:** `cargo check -p acpid` clean
### Fix 1.5: ACPI Notify handling — ✅ DONE
- **Commit:** `da327cae` (acpid: implement AML Notify handling for device-specific event dispatch)
- **Status:** Notify opcode in AML interpreter dispatches to device's _LNN/_ENN method
- **Verification:** `cargo check -p acpid` clean
---
## P2: Phase 2-3 Fixes (Storage, Network, HID) — ✅ DONE
The audit identified 5 medium-priority fixes that unblock Phase 2 (DRM/KMS) and Phase 3 (KDE Plasma Wayland).
### Fix 2.1: intel-thc-hidd HID report decoding — ✅ DONE
- **Commit:** `98d7ecb4` (intel-thc-hidd: implement HID report decoding + evdev translation)
- **Status:** Replaces `loop { sleep(5s) }` with real HID report thread, parses descriptors, translates to evdev
- **Verification:** `cargo check -p intel-thc-hidd` clean
### Fix 2.2: PS/2 scancode sets 2/3 + Intellimouse2 — ✅ DONE
- **Commit:** `e34c6184` (ps2d: implement scancode sets 2/3 and Intellimouse2 protocol)
- **Status:** Adds scancode set 2 and 3 mappers, extended keys, Intellimouse2 4-byte packet handling
- **Verification:** `cargo test -p ps2d --lib` returns **9 passed** (3 original + 6 new)
### Fix 2.3: USB Attached SCSI (UAS) — ✅ DONE
- **Commit:** `c131fb13` (usbscsid: implement USB Attached SCSI (UAS) protocol)
- **Status:** Replaces empty `mod uas { // TODO }` with real UasProtocol: 4-stream setup, IU send/receive, sense data
- **Verification:** `cargo check -p usbscsid` clean
### Fix 2.4: NVMe multi-queue — ✅ DONE
- **Commit:** `4b0db467` (nvmed: implement multi-queue I/O with MSI-X)
- **Status:** Reads "Number of Queues" feature, allocates per-CPU I/O queues, MSI-X per queue, per-queue completion
- **Verification:** `cargo check -p nvmed` clean
### Fix 2.5: e1000d statistical counters — ✅ DONE
- **Commit:** `494b671c` (e1000d: implement statistical counter clearing)
- **Status:** Reads GORC/GOTCL/GOTCH/TOTL/TOTH/TPR/TPT/BPRC/MPRC with read-then-clear sequence
- **Verification:** `cargo check -p e1000d` clean
---
## P3: Architectural Refactor (HID Core Extraction) — ✅ CRATE DONE, DRIVER INTEGRATION QUEUED
The audit identified that the three HID drivers (usbhidd, i2c-hidd, intel-thc-hidd) all duplicate HID report parsing and usage-to-evdev mapping. A shared `redbear-hid-core` crate will replace this with a single canonical implementation.
### Fix 3.1: redbear-hid-core crate — ✅ DONE
- **New crate:** `local/recipes/drivers/redbear-hid-core/`
- **Commit:** `7b82f4d` (redbear-hid-core: initial implementation)
- **Code:** 2664 LoC across 8 source files
- **Tests:** 43 unit tests, all passing
- **Modules:**
- `descriptor.rs` (428 LoC) — HID Report Descriptor parser
- `item.rs` (328 LoC) — HID Item parser (Main/Global/Local)
- `usage_table.rs` (351 LoC) — usage page → evdev code mapping
- `translate.rs` (206 LoC) — HID Report → evdev events
- `quirks.rs` (978 LoC) — HID quirk table
- `report.rs` (126 LoC) — parsed HID Report
- `test_fixtures.rs` (225 LoC) — synthetic Report Descriptors for tests
- `lib.rs` (22 LoC) — re-exports
- **Usage pages covered:**
- 0x01 Generic Desktop (Pointer, Mouse, Keyboard, X, Y, Wheel)
- 0x07 Keyboard/Keypad (all 0x00-0xE7 mapped to KEY_*)
- 0x09 Button (BTN_MOUSE / BTN_LEFT-RIGHT)
- 0x0C Consumer (Volume, Play/Pause)
- 0x0D Digitizer (Touchscreen, Touchpad)
- 0x01 Game Controller (X, Y, Z, Rx, Ry, Rz, Hat Switch)
- **Quirks supported:** Invert, Notouch, MultiInput, SkipOutput, NoEmpty
### Fix 3.2: usbhidd → redbear-hid-core — QUEUED
- **Target:** `local/sources/base/drivers/input/usbhidd/`
- **Work:**
- Replace hardcoded KEY_* array with dynamic Report Descriptor parsing via redbear-hid-core
- Wire usage → evdev translation through the new crate
### Fix 3.3: i2c-hidd → redbear-hid-core — QUEUED
- **Target:** `local/sources/base/drivers/input/i2c-hidd/`
- **Work:**
- Replace boot-protocol-only code with full Report Protocol parsing
- Wire usage → evdev translation through the new crate
### Fix 3.4: intel-thc-hidd → redbear-hid-core — QUEUED
- **Target:** `local/sources/base/drivers/input/intel-thc-hidd/`
- **Work:**
- Wire HID report decoding through the new crate
- (Depends on Fix 2.1 which is DONE)
---
## P4: Network Driver Hardening
The audit identified gaps in MSI-X support, PHY handling, and modern virtio-net features.
### Fix 4.1: ixgbed MSI-X
- **Target:** `local/sources/base/drivers/net/ixgbed/`
- **Work:**
- Enable MSI-X for the queue pairs
- Set up per-queue interrupts
### Fix 4.2: RTL8168 PHY
- **Target:** `local/sources/base/drivers/net/rtl8168d/`
- **Work:**
- PHY link state detection
- Auto-negotiation
- Speed/duplex configuration
### Fix 4.3: virtio-net control queue
- **Target:** `local/sources/base/drivers/net/virtio-netd/`
- **Work:**
- Use the control virtqueue for MAC address setting
- Implement the modern virtio-net 1.1 control queue
### Fix 4.4: RTL8139 PHY
- **Target:** `local/sources/base/drivers/net/rtl8139d/`
- **Work:**
- PHY link state detection
- Auto-negotiation
---
## P5: ACPI Completeness
The audit identified missing ACPI features: Embedded Controller, Thermal, Battery, Wake.
### Fix 5.1: ACPI Embedded Controller
- **Target:** `local/sources/base/drivers/acpid/ec.rs`
- **Work:**
- EC transactions (read/write/query)
- EC interrupts (SCI on EC events)
- Used by many laptops for fan control, hotkeys, etc.
### Fix 5.2: ACPI Thermal
- **Target:** `local/sources/base/drivers/acpid/`
- **Work:**
- Parse \_TZ (thermal zone) objects
- Read \_TMP, \_TC1, \_TC2, \_TSP, \_PSV, \_CRT
- Notify on critical temperature
### Fix 5.3: ACPI Battery
- **Target:** `local/sources/base/drivers/acpid/`
- **Work:**
- Parse battery device (PNP0C0A)
- Read \_BST (Battery Status) and \_BIF (Battery Information)
- Notify on status change
### Fix 5.4: ACPI Wake
- **Target:** `local/sources/base/drivers/acpid/`
- **Work:**
- Parse \_PRW (Power Resources for Wake)
- Implement S1, S3 (suspend to RAM) transitions
- Resume from S3 on wake event
---
## P6: Storage Driver Hardening (not started)
### Fix 6.1: AHCI NCQ
- **Target:** `local/sources/base/drivers/storage/ahcid/`
- **Work:**
- Native Command Queuing for SATA SSDs
- Read LOG_PAGE_LOG_DIRECTORY for drive capabilities
### Fix 6.2: NVMe TRIM/DISCARD
- **Target:** `local/sources/base/drivers/storage/nvmed/`
- **Work:**
- Implement Dataset Management command for SSD TRIM
---
## P7: Audio Driver Hardening (not started)
### Fix 7.1: AC'97 full duplex
- **Target:** `local/sources/base/drivers/audio/ac97d/`
- **Work:**
- PCM capture (record) in addition to playback
- Mixer controls
### Fix 7.2: Intel HDA codec
- **Target:** `local/sources/base/drivers/audio/ihdad/`
- **Work:**
- Full codec initialization
- HDMI/DP audio support
- Multiple streams per codec
---
## P8: Graphics Driver Hardening (not started)
### Fix 8.1: Intel iHD real implementation
- **Target:** `local/sources/base/drivers/graphics/ihdgd/`
- **Work:**
- Use linux-kpi for full i915 compat
- Real connector enumeration
- Atomic modeset
- GPU command submission
### Fix 8.2: virtio-gpu virgl
- **Target:** `local/sources/base/drivers/graphics/virtio-gpud/`
- **Work:**
- 3D resource creation via virgl
- Mature 3D support for QEMU
---
## Risk Assessment
What's the impact of shipping as-is?
- QEMU works (poll-mode USB, single-queue NVMe, no multi-touch)
- Real hardware has degraded USB, no touchpad (intel-thc-hidd stub), no power button, no lid switch, no thermal protection
What's the minimum to ship Red Bear OS 0.3.0?
- P1: xhcid MSI-X, xhci event ring growth, PCI multi-bus
- P2: intel-thc-hidd HID, PS/2 set 2/3, NVMe multi-queue
- P3: redbear-hid-core
What's the minimum to ship Red Bear OS 0.4.0 (KDE Plasma Wayland)?
- All of P1, P2, P3
- P4: ixgbed MSI-X, RTL8168 PHY
- P5: ACPI thermal (for laptop safety)
What's the minimum to ship Red Bear OS 0.5.0 (real-hardware KDE)?
- All of P1, P2, P3, P4
- P5: full ACPI completeness
- P6: AHCI NCQ, NVMe TRIM
---
## Verification Strategy
For each fix:
1. `cargo check -p <package>` returns 0 errors
2. (If applicable) `cargo test -p <package>` returns all tests passed
3. (If applicable) QEMU bare-metal boot
4. (If applicable) Real-hardware smoke test
Cross-cutting:
- `cargo check --workspace` clean across all of `local/sources/base/`
- `cargo check --workspace` clean across all of `local/recipes/`
- All four audit documents are updated to mark the fixed items
---
## Open Questions
1. **MSI-X vector cap**: should we cap at 32, 64, or 128? Modern xHCI supports up to 1024 vectors.
2. **Event ring max size**: 4096 TRBs? 8192? More?
3. **NVMe queue count**: cap at 64, 128, or 256?
4. **redbear-hid-core license**: MIT, Apache-2.0, or dual-licensed? Project preference is MIT.
5. **HID quirks table**: how many quirks to include initially? 50? 100? 500?
6. **ps2d set 3 priority**: is it actually used by any current hardware?
---
**Status:** 11 fixes dispatched in parallel. Waiting for completion notifications.
---
## Round 2: GPU/Mesa/KDE Build Chain + Forks (2026-06-09)
After the v6.0 single-producer input + driver stub-fix campaign finished, the GPU-Mesa-KDE assessment (`GPU-MESA-KDE-CHAIN-ASSESSMENT.md`, 1379 lines) was produced and the following work landed in a second round:
### New Red Bear source forks established
| Fork | Path | Initial commit | Notes |
|------|------|----------------|-------|
| `libdrm` | `local/sources/libdrm/` | `26e0c24 libdrm: Red Bear fork with redox patches applied` | libdrm 2.4.125 + 1542-line `redox.patch` (P1-P4 patch series folded into single in-tree patch) |
| `redox-drm` | `local/sources/redox-drm/` | `bd787d3 redox-drm: Red Bear fork with Intel/AMD/virtio drivers` | DRM/KMS scheme daemon — renderD128 path, atomic_check connector validation, Gap 3 / Gap 5 / Gap 8 fixes |
| `pipewire` | `local/sources/pipewire/` | `829d32e pipewire: initial import of upstream 0.3.85 fork` | Plus `016669f pipewire: add Redox compat shims` |
| `wireplumber` | `local/sources/wireplumber/` | `df92c0b wireplumber: initial import of upstream 0.4.14 fork` | Session manager for PipeWire |
### Mesa fork (work in progress)
The mesa recipe is being migrated from `recipes/libs/mesa` (Redox upstream) to `local/sources/mesa` so EGL Wayland work can land. Commit `6267d2451 mesa: fork mainline recipe to local for EGL Wayland work (Phase 2.1)` is the first commit on the new fork.
### Key conflicts resolved
- **amdgpu `idr_*` linux-kpi conflict** — resolved with `REDBEAR_AMDGPU_BUILD` guard (commit `638d78ee9`)
- **amdgpu re-enabled in redbear-full.toml** (was previously `"ignore"`) — commit `52459b787`
- **SDDM mayagrid theme** doesn't exist (only `maya`, `elarun`, `maldives` are shipped) — fixed to `maya` (commit `ebeb737f1`)
- **SDDM plasmawayland.desktop Exec** — fixed from `kwin_wayland --drm ...` to `startplasma-wayland` (commit `ebeb737f1`)
### Refusals (correctly so)
Two agents refused to perform tasks that would have been policy violations:
1. **"Implement redbear-qml-runtime Rust shim"** — the agent verified that `QQuickWindow` and `QQmlEngine` already exist as real C++ classes in the built `libQt6Qml.so` and `libQt6Quick.so`. A `pub struct` in Rust cannot satisfy the C++ ABI that kirigami/Plasma links against. Refused to write a stub. The actual blocker is D-Bus activation, KWin Wayland compositing on Redox, libepoxy symbol resolution, and fontconfig setup — none of which a "Rust shim" addresses.
2. **"Promote Wayland recipes to local/recipes/"** — the agent verified that `libwayland` and `wayland-protocols` are already in `local/recipes/wayland/` (the wip entries are symlinks to the local overlay). Nothing to move.
### QEMU boot test
`bg_3ec3f2af` — runs `./local/scripts/build-redbear.sh redbear-full` then boots it in QEMU 11.0.0 with virtio-gpu, captures serial output to `local/docs/boot-logs/`, writes summary. **This is the runtime validation step the v6.0 changelog identifies as "the only remaining Phase 1 gate."** Status: in progress.
### Submodule reconciliation
`bg_1b967047` — commits uncommitted changes in 10+ submodules (kernel, installer, sddm, redbear-notifications, redbear-statusnotifierwatcher, uutils-tar, ninja, llvm, mesa, base, etc.) and advances the main repo's submodule pointers. Status: in progress.
### Round 2 commit summary (commits added on top of round 1)
| Commit | Description |
|--------|-------------|
| `6870429b2` | libdrm: migrate to Red Bear fork; apply redox patches in-tree |
| `638d78ee9` | amdgpu: resolve idr_* conflict with linux-kpi via REDBEAR_AMDGPU_BUILD |
| `52459b787` | redbear-full: re-enable amdgpu (v6.0 2026, 0.2.3) |
| `796875e93` | redox-drm: switch recipe to local/sources/redox-drm fork, bump 0.2.3 |
| `f7f98fe67` | redox-drm: switch recipe to local/sources/redox-drm fork, bump 0.2.3 (canonical) |
| `6267d2451` | mesa: fork mainline recipe to local for EGL Wayland work (Phase 2.1) |
| `32993a9ee` | redox-drm: validate connector state in atomic_check (Gap 8 fix) |
| `19763b3ce` | plan: mark Gap 5 (host->guest resize events) and Gap 8 (atomic_check connectors) done |
| `b6ed9cab1` | build-redbear: stop nuking entire repo when a low-level source is stale |
| `ebeb737f1` | sddm: fix theme to maya; fix plasmawayland.desktop Exec to startplasma-wayland |
| `ddd574ef4` | redbear-compositor: keep DRM fd open across page flips (Gap 3.5) |
| `93740b7c0` | plan: add v6.0 changelog (Phase 1 fully implemented in code) |
| `385240174` | plan: mark Step 1.9 (udev-shim eventN) done |
---
**Total session commits:** 319+ in main repo on `0.2.3` branch (Gitea remote).
**New forks:** 4 (libdrm, redox-drm, pipewire, wireplumber) at `local/sources/`.
**New local/recipes subdirectories:** `data/`, `wayland/`, `libs/redbear-qml-runtime/` (planned), `libs/pipewire/`, `libs/wireplumber/`, `libs/libxkbcommon/`, `drivers/redbear-hid-core/`.
---
## Architectural Decision: Red Bear Forks vs. Direct Edits (2026-06-09)
This section records the policy decision for **where Red Bear source modifications must live**.
It is the durable, in-tree statement of the two-rule model already encoded in
`local/AGENTS.md` under "NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026)".
### The policy in one sentence
> **Big external projects (mesa, wayland, qt, KF6, KWin, SDDM, llvm, libdrm, redox-drm, libepoxy,
> pipewire, wireplumber, …) must live as Red Bear forks at `local/sources/<component>/`, not as
> direct edits inside the mainline `recipes/<pkg>/source/` tree.**
### Why
Direct edits to `recipes/<pkg>/source/` are **clobbered by `make clean` and by upstream syncs**.
A Red Bear fork at `local/sources/<component>/` is a separate git repo, owned by Red Bear,
git-tracked, rebase-friendly, and never touched by the build system's source-regeneration step.
It survives every `make clean`, every `make distclean`, every `provision-release.sh`, and every
upstream `git pull` we ever run.
### The 12 Red Bear forks already in place (verified 2026-06-09)
| # | Fork | Path | Why a fork |
|---|------|------|------------|
| 1 | `base` | `local/sources/base/` | Red Bear userspace drivers fork — acpid, pcid, inputd, ps2d, xhcid migrations |
| 2 | `bootloader` | `local/sources/bootloader/` | UEFI bootloader fork — UEFI alloc fix, branding, GPT offset |
| 3 | `installer` | `local/sources/installer/` | Installer fork — ext4 + GRUB support |
| 4 | `kernel` | `local/sources/kernel/` | Microkernel fork — ACPI, x2APIC, MSI/MSI-X, scheduling, branding |
| 5 | `libdrm` | `local/sources/libdrm/` | DRM/KMS userspace library — ioctl bridge, PCI info, device enumeration |
| 6 | `mesa` | `local/sources/mesa/` | Mesa 3D graphics library — virgl disk cache, GBM dumb prime export, hardware driver work |
| 7 | `pipewire` | `local/sources/pipewire/` | PipeWire audio server — Redox compat shims |
| 8 | `redox-drm` | `local/sources/redox-drm/` | DRM/KMS scheme daemon — Intel + AMD display drivers, MSI/MSI-X fallback, DISABLE_ACCEL |
| 9 | `redoxfs` | `local/sources/redoxfs/` | RedoxFS — primary filesystem, Red Bear schema/improvements |
| 10 | `relibc` | `local/sources/relibc/` | C library — eventfd, signalfd, timerfd, waitid, SysV IPC, credential syscalls |
| 11 | `userutils` | `local/sources/userutils/` | Userland utilities — login/getty/login helpers, prompt/welcome text |
| 12 | `wireplumber` | `local/sources/wireplumber/` | WirePlumber session manager — PipeWire policy |
**Verification command:**
```bash
ls -1 /home/kellito/Builds/RedBear-OS/local/sources/
# Expected (12 entries):
# base bootloader installer kernel libdrm mesa
# pipewire redox-drm redoxfs relibc userutils wireplumber
```
### The exception: in-tree Red Bear components
`kernel`, `relibc`, `base`, `installer`, and `bootloader` are listed in **both** the
"in-tree Red Bear components" and the "forks at `local/sources/`" tables above. That is
intentional. These components are forked at `local/sources/<component>/` (Rule 2 — big
project, durability matters), but the mainline `recipes/<category>/<component>/recipe.toml`
**points at the fork** (not the other way around — no symlink, no overlay, no patch
file). The fork IS the source of truth; the recipe just builds it.
For **small Red Bear-initiated new packages** (cub, redbear-info, redbear-netctl,
redbear-sessiond, redbear-authd, …) the rule is Rule 1: a `local/recipes/<category>/<name>/`
fork replaces the upstream recipe entirely. No symlinks, no overlay layer.
For **upstream Redox system internals that we do not modify** (core/pkgar, core/ion,
core/dash, core/coreutils, gui/orbital, …) we pull from upstream at a pinned revision
and the build is fine. The Redox ABI must not diverge.
### Concrete walk-through: direct edit vs. fork
**Scenario:** You want to add `-Dplatforms=wayland` to the Mesa build to enable the
Wayland EGL platform, which is the prerequisite for KWin to find an EGL/GBM/GLES2 surface.
#### Direct edit (WRONG — Rule 1 anti-pattern)
1. Edit `recipes/libs/mesa/recipe.toml` to add `-Dplatforms=wayland` to the meson args.
2. Run `repo cook recipes/libs/mesa`. The build succeeds. Mesa now exposes Wayland EGL.
3. Two days later, upstream Mesa 25.0 is released.
4. You run `make distclean` (or `make clean` or `repo fetch recipes/libs/mesa`).
5. The cookbook refetches Mesa from the pinned git URL. The `recipe.toml` is overwritten
with whatever is at the new rev. **Your `-Dplatforms=wayland` change may be wiped,
may be preserved, or may collide with a new upstream flag. Outcome is non-deterministic.**
6. If the recipe `rev` is bumped, the source tree is also refetched. Your hand-edited
Meson build files inside `recipes/libs/mesa/source/` are GONE.
7. If you try to recover by re-applying, you are now maintaining a patch series on top
of multi-million-line upstream Mesa. Every upstream bump is a `git apply` rebase.
8. **Your Red Bear patches are LOST or have become unmaintainable.**
#### Fork (CORRECT — Rule 2, what we actually do)
1. The Mesa fork is already at `local/sources/mesa/`, on branch `0.2.3`, with our existing
EGL Wayland commits. (See `local/sources/mesa/` for the current state.)
2. Add a Red Bear commit on `local/sources/mesa/0.2.3`:
```bash
cd local/sources/mesa
# Edit meson.build, meson_options.txt to add Wayland EGL platform support
git add meson.build meson_options.txt
git commit -m "mesa: enable Wayland EGL platform (-Dplatforms=wayland) for KWin"
```
3. The mainline `recipes/libs/mesa/recipe.toml` already points at the fork:
```toml
[source]
path = "../../../local/sources/mesa"
```
No change needed there.
4. Run `./local/scripts/build-redbear.sh redbear-full`. Mesa builds with Wayland EGL.
The build artifact lands in `repo/x86_64-unknown-redox/mesa.pkgar` + `mesa.toml`.
5. Two days later, upstream Mesa 25.0 is released. We want to pull it.
6. Bump the upstream reference in the fork:
```bash
cd local/sources/mesa
git remote add upstream https://gitlab.freedesktop.org/mesa/mesa.git # one-time
git fetch upstream
git checkout 0.2.3
git rebase upstream/25.0 # rebase OUR patches on top of new upstream
# Resolve the (rare, well-localized) conflicts in meson.build, meson_options.txt
git push origin 0.2.3
```
7. The mainline recipe's `rev` is updated in `local/recipes/libs/mesa/recipe.toml` (or
in the upstream mainline recipe that points at the fork), and the build proceeds.
8. **Our Red Bear patches SURVIVE — they live on the `0.2.3` branch of our fork, are
rebased forward at our discretion, and are visible in `git log` of the fork.**
### Rule-of-thumb decision matrix
| Is the component … | Then … |
|---|---|
| An in-tree Red Bear core (kernel, relibc, base, installer, bootloader) | **Rule 1 + Rule 2 hybrid** — fork at `local/sources/<component>/` is the source of truth; mainline recipe points at the fork. No patches, no symlinks. |
| A small Red Bear-initiated new package (cub, redbear-info, redbear-netctl, redbear-sessiond, redbear-authd, …) | **Rule 1** — `local/recipes/<category>/<name>/` fork replaces the upstream recipe. No symlinks, no overlay. |
| A big external project (mesa, wayland, qt, KF6, KWin, SDDM, llvm, libdrm, redox-drm, libepoxy, pipewire, wireplumber, …) | **Rule 2** — Red Bear fork at `local/sources/<component>/`. Mainline recipe points at the fork via `path = "../../../local/sources/<component>"` or `git = "https://gitea.redbearos.org/redbear/<component>.git"`. |
| An upstream Redox system-internal that we do not modify (core/pkgar, core/ion, core/dash, core/coreutils, gui/orbital, …) | No fork. Pull from upstream at pinned revision. The Redox ABI must not diverge. |
| A pure Cargo dep that we do not fork (redox_syscall, libredox, redox-scheme, pkgar, …) | Pulled via Cargo from upstream crates.io. No recipe. |
The default for anything multi-thousand-line external is **Rule 2 (fork)**.
The default for anything Red Bear-initiated is **Rule 1 (local recipe that replaces upstream)**.
In-tree Red Bear core components live at `local/sources/<component>/` and the mainline
recipe points at them.
### Cross-references
- `local/AGENTS.md` — "NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026)" sections,
Rule 1 (in-tree Red Bear components) and Rule 2 (big external projects).
- `local/AGENTS.md` — "SOURCE-OF-TRUTH RULE" section, two-layer architecture
(`recipes/*/source/` is ephemeral; `local/sources/`, `local/recipes/`, `local/docs/`,
tracked configs are durable).
- `local/AGENTS.md` — "STUB AND WORKAROUND POLICY — ZERO TOLERANCE" for what to do when
a fork's build breaks (fix it in the fork, never disable features in the consumer).
- `local/AGENTS.md` — "DESIGN PRINCIPLE" and "RELEASE MODEL (FORK — NOT OVERLAY)" for
the upstream-baseline + fork-on-top architecture.
- `local/AGENTS.md` — "STRUCTURE" for the full directory map.
- `local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md` — canonical desktop path plan that consumes
the mesa, wayland, qt, KF6, KWin, SDDM, libdrm, redox-drm, libepoxy forks.
### Audit commands
Verify no overlay state has crept back into the tree:
```bash
# (a) Every recipe must have exactly one source — no duplicate recipe.toml,
# no symlinks hiding the fork.
find recipes/ -name "recipe.toml" -path "*/local/*" -o -lname "*/local/*" 2>/dev/null
# (b) Every Red Bear fork at local/sources/ must be a git repo.
for d in local/sources/*/; do
[ -d "$d/.git" ] || echo "MISSING .git: $d"
done
# (c) Every mainline recipe that claims a fork must point at the right path.
grep -r "local/sources/" recipes/ --include="recipe.toml" | head -50
```
If any of these checks return unexpected output, the build is in an overlay state. Fix by
forking the recipe properly per `local/AGENTS.md` Rule 1 or Rule 2.
**Decision date:** 2026-06-09
**Decision authority:** `local/AGENTS.md` "NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026)"
**Verification status:** 12 of 12 expected Red Bear forks present at `local/sources/`.
**Out-of-scope:** This section does not change the per-component build flags, the
`redbear-full` package set, or the relibc POSIX surface — those are tracked in
`local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md`, `local/docs/STUBS-FIX-PROGRESS.md` Phase tables,
and `local/recipes/` per-component recipes respectively.