4.3 KiB
Red Bear OS Patch Governance
Purpose
This document prevents loss of implemented work. It establishes rules that AI agents and human contributors must follow when modifying patches, recipes, or build configs.
Incident: 2026-04-26 Driver Code Loss
A previous agent session removed 8 patches and 9 BINS entries from
recipes/core/base/recipe.toml to make the build succeed, instead of fixing
patch conflicts. This deleted GPIO/I2C/UCSI driver source code that took a full
day to implement (commits dc3f1f996, 3054adc5d).
The code was recovered from git history, but this must never happen again.
Rules
1. Never remove patches to fix build failures
When a patch fails to apply:
- Rebase the patch against the current cumulative state
- Fix the context lines so the hunk applies cleanly
- Split the patch if only some hunks fail (keep the working hunks)
- Document the failure reason in the patch file header
Do NOT remove the patch from the recipe.toml patches list without explicit user approval. If a patch must be temporarily disabled, comment it with a TODO explaining why and what needs to be fixed.
2. Never remove BINS entries to fix build failures
When a driver binary fails to compile:
- Fix the compilation error in the driver source
- Add the driver to EXISTING_BINS filter if source is incomplete
- Document the failure
Do NOT remove the driver from the BINS array without explicit user approval.
3. Patch ordering matters
Patches in recipes/core/base/recipe.toml must be applied in the listed order.
Some patches have interdependencies:
P2-acpi-i2c-resources.patchmust apply beforeP2-daemon-hardening.patch(workspace entries reference source files created by the former)P2-boot-runtime-fixes.patchmodifies hwd/acpi.rs (must apply cleanly to upstream)P2-init-acpid-wiring.patchadds 41_acpid.service and pcid-spawner retry logic (acpid spawn removal is in P2-boot-runtime-fixes, do NOT duplicate)
When reordering patches, test the FULL chain: remove source, rebuild, verify.
4. Recipe.toml is tracked, source trees are not
recipes/core/base/recipe.toml is git-tracked. Changes to it are durable.
recipes/core/base/source/ is a fetched working copy — destroyed by make clean,
make distclean, source refresh, and sync-upstream.
Any change to source/ MUST be preserved as a patch in local/patches/base/.
5. Before removing anything, check git history
git log --oneline --all -- <file>
If a previous commit added substantial work (driver implementations, features), the removal MUST be approved by the user. Agent sessions MUST NOT delete implemented work to bypass build failures.
6. Build validation after patch changes
After ANY change to the patches list or patch files:
- Remove the source tree:
rm -rf recipes/core/base/source - Full rebuild:
REDBEAR_ALLOW_PROTECTED_FETCH=1 CI=1 make r.base - Verify NO "FAILED" or "rejects" in output
- Verify all expected binaries in stage:
ls stage/usr/bin/ stage/usr/lib/drivers/ - Full image build:
CI=1 make all CONFIG_NAME=redbear-full
Known Issues
| Patch | Status | Notes |
|---|---|---|
| P2-acpid-core-refactor.patch | Needs rebasing | 13/15 hunks fail on acpid/scheme.rs; removed from recipe.toml with TODO |
| P2-acpi-i2c-resources.patch | Stripped | Removed stale acpid hunks that duplicated P2-boot-runtime-fixes; driver source hunks intact |
| P2-boot-runtime-fixes.patch | Needs rebasing | Context lines from monolith split are stale; hwd/acpi.rs hunk fails on clean upstream |
| P2-init-acpid-wiring.patch | Deduplicated | Removed acpi.rs hunk that duplicated P2-boot-runtime-fixes |
Recipe.toml Fix Log
| Date | Change | Why |
|---|---|---|
| 2026-04-26 | Restored 8 removed patches | Agent deleted them to bypass conflicts; restored all from git HEAD |
| 2026-04-26 | Restored 9 BINS entries | Agent deleted i2cd, gpiod, ucsid, etc. to bypass missing sources |
| 2026-04-26 | Added EXISTING_BINS grep loop | Gracefully handles missing driver source instead of build failure |
| 2026-04-26 | Fixed grep/find variables | ${GREP} and ${FIND} are unset in redoxer env; use bare grep/find |
| 2026-04-26 | Fixed TOML escaping | \" in TOML triple-quotes becomes " in bash; use \\\" for literal " |