Files
sergio f8a2547b45 feat(arje-incarnate): A5 — pivot_root + OverlayFS
Dos ChildPreExec nuevos en el hook declarativo pre-execve:
- MountOverlay { target, options } — monta OverlayFS (capa base RO +
  capa de sesión RW + workdir).
- PivotRoot { new_root, put_old, old_root_after } — bind-mount de
  new_root sobre sí mismo + pivot_root + chdir("/") + umount2 lazy
  (MNT_DETACH) del root viejo.

Builders ergonómicos en ChildSetup:
- with_overlay(lower, upper, work, merged)
- with_pivot_root(new_root, put_old_name)

Ambas ops corren en el hijo post-clone, dentro del mount namespace,
async-signal-safe (solo libc, sin allocator). Las consumirán mirada
(compositor Wayland) y matilda Ghost para rootfs aislados.

19 tests arje-incarnate verdes (3 nuevos: builders overlay/pivot).
cargo check --workspace verde. Pendiente: integration test en entorno
con namespaces reales.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 00:35:31 +00:00

51 lines
2.3 KiB
Markdown

# init/ — Init (PID 1) y encarnación Linux
**Propósito.** `arje-zero` arranca como PID 1 del fractal. Provee el
bucle primordial (reap + bus + handshake), bootstrap del kernel
surface, encarnación de Cards en procesos aislados con namespaces +
cgroups, y snapshot/restore del grafo.
## Crates
| crate | tipo | rol |
| ---------------- | ------- | ----------------------------------------------------- |
| `arje-zero` | binario | PID 1: reap + handshake server + bus dispatcher |
| `arje-kernel` | lib | `bootstrap_kernel_surface`, subreaper, SIGCHLD/uevent |
| `arje-soma` | lib | Wrapper 44 LOC sobre `arje-incarnate` (compat API) |
| `arje-incarnate` | lib | `clone(2) + namespaces + cgroup + rlimits + cpu` |
| | | + `pivot_root` + OverlayFS (capa base RO + sesión RW)|
| `arje-snapshot` | lib | `FractalSnapshot` JSON: checkpoint del grafo Cards |
## Dependencias
- `arje-kernel``nix`, `libc`, syscalls Linux puras.
- `arje-incarnate` reusable: shuma (sandboxes) y supervisores no-PID-1.
- Consume `protocol/` (handshake server, brahman-net opcional).
## Boot path
1. Kernel pasa control → `arje-zero` arranca como `/sbin/init`.
2. Levanta sockets: `/run/brahman/bus`, `/run/brahman/handshake`.
3. Lee `Card` semilla (`seeds/arje-{minimal,host,prod}.card.json`).
4. Para cada `genesis` child Card: `incarnate(card)` → spawn aislado.
5. Reap loop atiende SIGCHLD; bus loop atiende anuncios/invokes.
## Encarnación de rootfs aislado
`arje-incarnate` expone vía `ChildSetup` (hook pre-execve declarativo):
- `with_overlay(lower, upper, work, merged)` → monta OverlayFS:
capa base RO + capa de sesión RW + workdir.
- `with_pivot_root(new_root, put_old_name)``pivot_root` + chdir +
desmontaje lazy (`MNT_DETACH`) del root viejo.
Ambas corren en el hijo, post-clone, dentro del mount namespace,
async-signal-safe. Las consumen `mirada` (compositor) y `matilda` Ghost.
## Estado
Funciona bare metal + QEMU + initramfs (ver `docs/arje-boot.md`). LOC
~2.2K en init core. `arje-incarnate`: 19 tests verdes (incluye builders
de overlay/pivot_root). Pendiente: integration testing de pivot_root +
OverlayFS en entorno con namespaces reales; cobertura de snapshot
restore con stale fds.