# Deployment & operations

> Listener tiers, LAN multi-user, outbound Magic Link tunnels, hot-reloaded prompts, GitOps export and backups.

## Three listener tiers

```yaml
listeners:
  unix_socket: "~/.kernuq/run/kernuq.sock"   # L1: local pipe bound to the real OS user (0600)
  http:
    bind: "127.0.0.1:7680"                   # loopback only by default
    lan_mdns:
      enabled: false                         # L2: advertise kernuq-studio.local for LAN sign-in
  outbound_scoped_tunnel:
    enabled: false                           # L3: project scoped approval / form Magic Links on demand
    magic_link_ttl_minutes: 120
```

- **L1 local** — the owner needs no login.
- **L2 LAN** — multi-user office sign-in; enable mDNS and bind to a LAN address.
- **L3 internet** — no inbound ports; an outbound tunnel projects read-only / scoped Magic Links with the control plane hard-isolated.

When serving the console over HTTPS, set `KERNUQ_CONSOLE_ORIGIN` to the full public origin (passkeys depend on it).

## Prompts are resources

Kernel prompts live in `prompts/system/*.prompt.md` and are embedded at compile time as a fallback. At runtime they load by priority — SQLite tuned version → config override → embedded — with `fsnotify` hot reload:

```yaml
prompts:
  hot_reload: true
  keep_last_known_good_on_error: true
  override_dir: "~/.kernuq/prompts"
```

## GitOps

```bash
kernuq export --db ~/.kernuq/data/kernuq.db --dir ./exported-bundle
git -C ./exported-bundle add -A && git -C ./exported-bundle commit -m "snapshot"
kernuq import --config ./exported-bundle/kernuq.yaml --dry-run --json
```

## Storage and backup

Data lives in `~/.kernuq/data/kernuq.db` (SQLite WAL). The authoritative track uses `synchronous=FULL` for zero loss on power failure. Back up with SQLite's online backup, or stop the daemon before copying the file.

## Proxy

Outbound traffic can be routed through SOCKS5 with bypass rules:

```yaml
network:
  socks5_proxy:
    enabled: true
    url: "socks5h://127.0.0.1:1080"
    bypass: ["127.0.0.0/8", "10.0.0.0/8", "192.168.0.0/16"]
```
