lore-forge/.ai/designs/deployment.md

5.5 KiB

Deployment

Status: first production shape built 2026-11-26; the e2e test covers its TLS and backup paths, the systemd units and installer have not yet run on Linux. Operator instructions are in deploy/README.md.

Decisions

Topic Decision Source
Host One Linux machine with systemd; lore-forge and loreserver as two units Owner, 2026-11-26
Reach and certificate One public hostname for both: the forge on 443 and loreserver on 41337 (UDP and TCP), sharing one Let's Encrypt certificate Owner, 2026-11-26
Proxy Caddy obtains the certificate and proxies to lore-forge over h2c; loreserver reads a copy of the same certificate Owner, 2026-11-26
Backups Copy the store live, stop loreserver, copy again with the database, start it; nightly, 14 kept, hard links between them Owner, 2026-11-26
Lore config Generated in full by lore-forge loreserver-config (trust, TLS, stores, ports, loopback HTTP), used by the units, scripts/start.sh and the e2e test alike Implementation choice
Secret key A root-only file handed to lore-forge as the systemd credential secret-key; never in backups Implementation choice
Remote shown to users LORE_FORGE_LORE_REMOTE, by default lores://<Lore URL host>, or lore:// for a loopback host Implementation choice

Layout

Caddy :80 :443 ──h2c──▶ lore-forge 127.0.0.1:8080 ── /var/lib/lore-forge
                           ▲ discovery, JWKS, registry and names (through https://host)
loreserver :41337 udp+tcp (TLS) ── /var/lib/loreserver/store
           127.0.0.1:41339 (HTTP, file content for lore-forge's browser)
  • Binaries under /opt/lore-forge/bin, settings in /etc/lore-forge/lore-forge.env, read by both units.
  • loreserver.service copies Caddy's certificate to /etc/loreserver/tls and writes its configuration to /run/loreserver/forge.toml before each start.
  • lore-forge-certs.path restarts loreserver when Caddy renews the certificate, because loreserver reads it only at startup.
  • loreserver only wants lore-forge, so restarting lore-forge does not restart it and drop its locks.

TLS ending at a proxy

A deployment whose proxy ends TLS on TCP 41337 (one public host relaying to loreserver on another over a private link) sets LORE_GRPC_TLS_AT_PROXY=1 for scripts/start.sh, or passes lore-forge loreserver-config --grpc-tls-at-proxy. The certificate is then written for [server.quic] only: QUIC cannot be ended at an ordinary proxy, so its TLS stays at loreserver, while gRPC is plaintext behind the proxy and lore-forge's browser reads it at http://127.0.0.1:41337 (owner, 2026-11-27). Checked by a unit test of the generated configuration; the e2e test does not run this shape.

Verified

In Lore v0.14.0's docs/reference/lore-server-config.md and lore-cli-config.md:

  • [server.grpc] serves TLS when it has a certificate block. Without one it is plaintext.
  • [server.http] has no TLS setting. Lore's clients do not use it; only lore-forge's browser reads file content there, so it is bound to 127.0.0.1.
  • lores:// validates the server certificate and is the default scheme. lore:// accepts any certificate on QUIC and sends gRPC, tokens included, without TLS.
  • The local lock store is an in-memory map. Every loreserver restart releases every lock.
  • loreserver re-fetches the JWKS on an unknown key ID, so key rotation needs no restart.

By scripts/e2e-lore.sh against the v0.14.0 release, on macOS:

  • loreserver loads a P-256 key in SEC1 form (EC PRIVATE KEY), which is how Caddy stores its keys, for both QUIC and gRPC.
  • The CLI, liblore (the desktop service) and lore-forge's browser all work over lores:// and TLS gRPC. They trust a private CA through SSL_CERT_FILE, so the clients use native roots plus that variable.
  • A client without the CA is refused, and so is a lore:// client against the TLS endpoint.
  • loreserver does not log a "listening" line at its default level. Readiness is checked with GET /health_check on the HTTP port.
  • A revision pushed just before scripts/backup.sh survives the SIGTERM stop and is in the backup. A restore brings back that state, drops a revision pushed after it, and serves both the CLI and the browser.

Assumed, not yet checked

  • The units, install.sh, lore-forge-certs and the Caddy site work as written on Debian 12 or Ubuntu 22.04+. None has run on Linux.
  • Caddy's package keeps certificates at /var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/<host>/.
  • Caddy passes Lore's gRPC (including streams) to lore-forge over h2c with flush_interval -1.
  • The server reaches itself at its public name (or through /etc/hosts).
  • Pushes and clones of real asset sizes (gigabytes) behave; the e2e pushes bytes.

Open

  • Locks across restarts. Backups, certificate renewals and upgrades restart loreserver, which releases every lock. Options: lore-forge keeps the lock list and re-takes locks after a restart, or a plugin lock store. To decide with the owner.
  • Durability between flushes. The local stores flush every 10 s. Whether an acknowledged push survives a crash, rather than a clean stop, is unchecked.
  • Off-machine backups. backup.sh writes to a local directory. Copying off the machine is left to the operator.
  • Upgrade testing. Moving to a new Lore release should be tried on a copy of the store first; there is no tooling for that yet.