Skip to content

The Recovery Protocol

Luiys edited this page Jul 23, 2026 · 1 revision

The Recovery Protocol

The restore command is the most critical piece of engineering in the Melina project. It is designed to fix a broken pacman database and rebuild corrupted system files without creating an infinite loop of destruction. The Threat: The Hook Paradox

If a user boots into the fallback {Melina} entry because their primary files are corrupted (zero bytes), running pacman -S linux to fix the system poses a massive risk. When pacman starts the reinstall, it will trigger the ALPM hook. The Bash Engine would then blindly copy the currently corrupted primary files over our pristine -safe backups, destroying the only working copy of the kernel.

The Solution: Disarm and Reconstruct

To prevent self-sabotage, the sudo melina restore command executes the following precise sequence:

  1. Disarm the Shield: The Ruby CLI forcefully deletes /etc/pacman.d/hooks/00-melina-shield.hook. This makes pacman blind to our backup engine.

  2. ALPM Database Query: It scans the system for installed core packages (linux, systemd, mkinitcpio, microcodes) ensuring it only attempts to reinstall software that actually belongs to that specific hardware architecture.

  3. Delegated Reconstruction: It executes pacman -S . With the shield disarmed, pacman freely downloads and extracts fresh, uncorrupted binaries to the ESP.

  4. Rearm the Shield: Once pacman finishes successfully, the Ruby CLI regenerates the .hook file.

  5. Update Fallback: Finally, it triggers melina-shield manually to create a brand new backup of the freshly repaired system.


This protocol ensures zero risk to the backup binaries while fully syncing the system state.

Clone this wiki locally