Skip to content

Architecture & Design Decisions

Luiys edited this page Jul 23, 2026 · 1 revision

Architecture & Design Decisions

Building a fail-safe system requires strict constraints and careful language selection. Here is the breakdown of the engineering tactics used in Melina.

Technology Stack: The Ruby & Bash Symbiosis

We deliberately chose a hybrid approach using Ruby and Bash to separate orchestration from execution.

  • Ruby (The CLI Orchestrator): Ruby was selected for the frontend CLI (melina) due to its excellent standard libraries (FileUtils, Open3) and object-oriented structure. It handles complex logic: checking OS release, calculating ESP byte size, validating constraints, and interacting with the user safely. It does not require installing external gems, keeping the footprint minimal.

  • Bash (The Execution Engine): The actual backup script (melina-shield) is written in pure Bash. Why not Ruby? Because this script is triggered by pacman hooks during system updates. Firing up a Ruby Virtual Machine in the middle of a critical package transaction introduces unnecessary overhead and points of failure. Bash executes in milliseconds, uses minimal memory, and relies solely on core POSIX utilities (cp, rm, stat).

Tactic 1: Pre-Transaction vs. Post-Transaction

Most backup or snapshot tools run after an update. Melina hooks into pacman using the PreTransaction trigger. If we used a PostTransaction hook, and the system crashed during the update, the hook would never run, and the system would be left unbootable. By executing before the transaction, we guarantee that the files we are backing up are the exact ones that successfully booted the current session.

Tactic 2: "Fail Fast" Engineering

The CLI implements a strict "Fail Fast" methodology. Before modifying any system files or installing hooks, the init command verifies:

  1. The presence of Arch Linux (via /etc/os-release).

  2. The active presence of systemd-boot (via bootctl status).

  3. The exact byte footprint of the target files against the available free bytes on the ESP.

If the ESP cannot safely hold the duplicated files, the installation aborts immediately, preventing a full disk scenario that could break the bootloader.

Clone this wiki locally