ADR-0016: Server operations — a Hetzner VPS behind Tailscale, rehearsed in a local runtime image, observed through journald + the CLI's OTel + Grafana Cloud
One record for how Jarvis runs unattended. It consolidates the former records 0015 (placement), 0017 (rehearsal) and 0018 (telemetry) without changing any of their decisions; the originals' full option analyses live in git history.
Context and Problem Statement
A laptop sleeps mid-task; the owner wants Jarvis always on, logged into claude with their own subscription (ADR-0003), with no public exposure, and needs to know — without SSH — whether Jarvis is alive and what each session cost. None of the server setup can be debugged for the first time on a paid box.
Decision Outcome
1. Placement: Hetzner VPS, host install, systemd, Tailscale only (formerly 0015)
- Ubuntu LTS, a non-root
jarvisuser owning~/.jarvis,~/.claudeand the checkout. Docker only for Postgres. Engine and web run on the host (worker runs need the target repo's toolchain), asjarvis-engine.service(pnpm --filter @jarvis/engine start) andjarvis-web.service(vite previewon127.0.0.1:5180, proxying/api), restart-on-failure, start-on-boot. - The owner logs into
claudeasjarvisover SSH once; credentials stay in that user's~/.claude. The ADR-0003 start-up guard is unchanged. - Nothing listens publicly: the firewall allows only SSH;
tailscale serve --bg 5180publishes the web app to the owner's tailnet only (preview.allowedHostscarries the ts.net name). - Deploy:
pnpm run redeploycalls the root-owned/usr/local/sbin/jarvis-deploy <sha>over SSH (§4); CI deploy can follow once stable.
2. Rehearsal: a Linux runtime image on the laptop; production stays bare systemd (formerly 0017)
docker/runtime: Ubuntu LTS, Node + pnpm via corepack,git,gh, Claude Code from the official installer, userjarvis(uid 1000).compose.yamlservicesengineandwebunderprofiles: [server]; without the profile the laptop workflow is unchanged.- The checkout,
~/.jarvis,~/.claudeand every workspace's Linuxnode_modulesare volumes;claude+/loginis run once in the container. - Only
127.0.0.1ports are published; inside the container processes may bind all interfaces — the published loopback mapping is where the rule from §1 is enforced (documented exception). - Not covered by the rehearsal: systemd itself, journald, Tailscale, the firewall. A green rehearsal proves the Linux filesystem, the user, Node/pnpm and the
claudelogin layout, nothing more.
3. Observability: journald + CLI OTel + one Alloy agent + Grafana Cloud; economics in Postgres (formerly 0018)
- The engine's JSON log on stderr (level
info, lifecycle events with fixedeventkeys andrunId/sessionId/taskId) goes to journald via the units; no log files, no engine OTel SDK. - A child
claudeexports its own OTel metrics/logs whentelemetry.enabled(default false); the engine only builds the environment.OTEL_LOG_USER_PROMPTS=0always; the child exports to the local Alloy on loopback and never receivesOTEL_EXPORTER_OTLP_HEADERSor any Grafana credential. - One Grafana Alloy agent on the host reads the
jarvis-engine/jarvis-webjournald units, receives the CLI's OTLP on127.0.0.1:4318, forwards to Grafana Cloud. Its credential lives in/etc/jarvis/alloy.env,root:alloy,0640;jarvisis not in groupalloy. - Liveness: a 60-second timer pings
HEARTBEAT_URL(healthchecks.io) from the engine's health check,/failon failed health, fire-and-forget; noHEARTBEAT_URL→ no timer. Silence is the signal a dead process cannot fake. - Session economics (cost, tokens, turns, stop reason) stay in Postgres (ADR-0008); budgets (LIM-04) and the Usage page read Postgres, never Grafana.
4. Hardening amendment: egress filter for uid jarvis and a root-owned deploy (2026-11-11)
- Untrusted project code (
prepare, check commands) runs as uidjarvis, directly or in rootless Docker, whose traffic leaves from the host namespace as that uid. An nftables tableinet jarvis_egress(deploy/hardening/egress.sh, loaded byjarvis-egress.service) dropsmeta skuid jarvistraffic to the tailnet (v4/v6), RFC1918, ULA, link-local and cloud-metadata ranges and the host's own public addresses; loopback stays open. Containers get public DNS and no search domain via the user'sdaemon.json. Root andtailscaledare untouched. - The owner API has no auth and is reachable on the tailnet, so a
jarvis-uid process must not reach it through the tailnet name; loopback access by the engine itself is intended. - Root never executes files from the
jarvis-writable checkout. Deploys run/usr/local/sbin/jarvis-deploy(root:root 0755, sourcedeploy/root/jarvis-deploy, installed only by the owner): it takes a 40-hex SHA, requires it to equal GitHub'smain, does git/pnpm/build/migrate asjarvisand only restarts and the health wait as root.deploy:remoteis removed; the host name comes fromJARVIS_HOST, not from the repository. - Residual risk: rootless Docker shares uid
jarviswith the engine. Next step: a dedicated Docker uid. Runbook:docs/architecture/deployment.md§7.
Consequences
- Good, because the PoC stays one machine and one user; losing the tailnet loses access, not data; with telemetry off (the laptop default) nothing leaves the machine.
- Good, because the headless
/login,.credentials.jsonmode and a clean Linuxpnpm installare tried in a free container before the server depends on them. - Bad, because the host carries state (Postgres volume,
~/.jarvis,~/.claude) and needs Hetzner snapshots plus a rebuild runbook; the subscription login lives on the server, so SSH is key-only and the tailnet holds only the owner's devices. - Bad, because a green rehearsal can give false confidence (units, journald, Tailscale untested until the VPS exists), and the laptop's Docker Desktop runs only while the owner is signed in.
- Bad, because three external accounts (Grafana Cloud, healthchecks.io, Infisical) and one more host agent; Grafana and Postgres can disagree on cost — Postgres wins.
- Risk: Claude Code's OTel variable and metric names can change between CLI versions; verify against the installed CLI before trusting the dashboard.
Confirmation
- RULE: No Jarvis port binds a public interface; engine, web and Postgres listen on
127.0.0.1(host) and the composeserverprofile publishes only127.0.0.1ports. CHECK:ss -tlnpon the server;docker compose --profile server config | grep -E "published|host_ip" - RULE: The runtime image runs as
jarvis(uid 1000), not root; noANTHROPIC_API_KEYanywhere. CHECK:docker compose --profile server run --rm engine id -u→1000; ADR-0003 start-up guard - RULE: The engine has no
@opentelemetrydependency;OTEL_*reaches a child only whentelemetry.enabled, withOTEL_LOG_USER_PROMPTS=0, and neverOTEL_EXPORTER_OTLP_HEADERS. CHECK:grep -c opentelemetry engine/package.json→0;engine/src/infrastructure/claude/env.test.ts - RULE:
jarvis.config.example.jsonshipstelemetry.enabled: false; no Grafana or heartbeat credential in any committed file; on the server/etc/jarvis/alloy.envisroot:alloy0640andjarvisis not in groupalloy. CHECK:grep -n '"enabled": false' jarvis.config.example.json;git grep -nE "(glc_|hc-ping\.com/[0-9a-f-]{36})"(expect none);stat -c '%a %U:%G' /etc/jarvis/alloy.env→640 root:alloy;id -nG jarvis | grep -wc alloy→0