zinit 0.3.7

Process supervisor with dependency management
Documentation
# zinit - Process Supervisor

A process supervisor with dependency management, similar to systemd but simpler.

## Quick Start

```bash
cargo check --workspace           # Verify builds
cargo test --workspace            # Run tests
cargo build --release --workspace # Build all binaries
```

## Crate Overview

| Crate | Purpose |
|-------|---------|
| `zinit-common` | Shared types, configs, RPC protocol, blocking client |
| `zinit-server` | Main daemon: supervisor, dependency graph, process management |
| `zinit-client` | CLI interface (optional TUI with `--features tui`) |
| `zinit-pid1` | PID 1 init shim for containers/VMs/bare-metal |

## Operating Modes

| Mode | Command | System init | Config sources |
|------|---------|-------------|----------------|
| VM/Bare-metal | `zinit init` | Full | `/etc/zinit/system` + `/etc/zinit/services` |
| Container | `zinit init -c` | None | `/etc/zinit/services` only |
| Standalone | `zinit-server` | None | Configured directory only |

## Documentation

```
docs/
├── adr/           # Architecture Decision Records
│   ├── 001-vm-baremetal-boot.md   # Boot architecture
│   ├── 002-shutdown-ordering.md   # Shutdown order design
│   └── 003-api-compatibility.md   # API decisions
├── spec/          # Technical specifications (00-10)
└── reference/     # API docs, design doc, openrpc.json
```

## Key Design

1. **State Machine**: 7 states (Inactive, Blocked, Starting, Running, Stopping, Exited, Failed)
2. **Dependency Graph**: petgraph with 4 dep types: `after`, `requires`, `wants`, `conflicts`
3. **Service Classes**: `user` (bulk ops) vs `system` (protected)
4. **IPC**: Unix socket with JSON-RPC protocol
5. **Process Groups**: Signals sent to PGID, handles `sh -c` children

## Config Format

```toml
[service]
name = "my-service"
exec = "/usr/bin/my-service --daemon"
class = "user"          # or "system"
critical = false        # if true, failure halts boot (PID1 mode)

[dependencies]
requires = ["database"]
after = ["logger"]

[lifecycle]
restart = "on-failure"
```

## Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `ZINIT_LOG_LEVEL` | `info` | Log level: info, debug, trace |
| `ZINIT_CONFIG_DIR` | `/etc/zinit/services` | Service config directory |
| `ZINIT_SOCKET` | `/var/run/zinit.sock` | Unix socket path |
| `ZINIT_CONTAINER` | unset | Set to skip system init in PID1 mode |

## Debug Commands

```bash
zinit debug-state           # Full graph state with deps, PIDs, uptime
zinit debug-procs <name>    # Process tree for a service
zinit status                # Service states
zinit why <name>            # Why a service is blocked
```

## Key Implementation Files

| File | Purpose |
|------|---------|
| `zinit-server/src/supervisor.rs` | Main event loop, service lifecycle |
| `zinit-server/src/graph.rs` | Dependency graph, ordering |
| `zinit-server/src/process.rs` | Process spawning, signals |
| `zinit-pid1/src/main.rs` | PID 1 implementation |
| `zinit-common/src/config.rs` | Service config parsing |