interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / infra / RUNBOOK.md
| 1 | # interplane.io and the forge: operations runbook |
| 2 | |
| 3 | Scope: the public site interplane.io (static pages plus forged) and the redirect from www.aienos.com/forge/ (since 2026-11-10), served from |
| 4 | the Spark since 2026-11-08. Deploy details live in `infra/DEPLOY.md` (written for the hub-era edge; |
| 5 | the same scripts and rules apply) and the front-door switch in `infra/spark/README-edge.md`. This file |
| 6 | covers running it: where the data is, how to renew, back up, restore, and what to do when a host is |
| 7 | down. Hosts: the Spark (`ssh spark`, LAN 192.168.1.108), the hub Pi (`ssh hub`, 192.168.1.192), the |
| 8 | operator Mac. Router: Calix at https://192.168.1.1. |
| 9 | |
| 10 | ## 1. Serving path |
| 11 | |
| 12 | ``` |
| 13 | client ─TCP 443─▶ router 74.167.68.53 ─port-forward─▶ Spark 192.168.1.108:443 |
| 14 | nginx stream SNI router (infra/spark/nginx/sni-router.conf, PROXY protocol on) |
| 15 | interplane.io, www.interplane.io ─▶ 127.0.0.1:4448 (ssl, proxy_protocol) → vhost sites-interplane.io |
| 16 | www.aienos.com, aienos.com ─▶ the aienos vhosts (`/forge/…` → 301/308 to https://interplane.io/…, DEPLOY.md "www.aienos.com/forge/ redirect") |
| 17 | hs.aienos.com ─▶ raw TCP to the Pi 192.168.1.192:443 (Headscale keeps its own TLS) |
| 18 | vhost interplane.io: static `/var/www/interplane.io` first (try_files), else forged 127.0.0.1:18480 |
| 19 | /status/uptime/ → alias /var/www/interplane-uptime/ (the probe page, section 6; the location is in forge/home-root) |
| 20 | /rad/ → 127.0.0.1:8780 → edge-rad-tunnel.service (ssh -L) → the Pi's radicle-httpd |
| 21 | forged: tmux session `forged` (infra/spark/forged-service.sh supervisor), binary ~/work/forge/web/server/forged |
| 22 | ``` |
| 23 | |
| 24 | - TCP 80 is not forwarded today (ops proposal; QW1 has a :80→301 change waiting for Drake's router rule). |
| 25 | - Static files are published to the Pi and mirrored to the Spark (section 7, edge-mirror). The |
| 26 | interplane.io publisher is `aien-run-interplane-sync.service` (aien-onchange on the Radicle refs of |
| 27 | z399yKv…, then `scripts/sync-to-hub.sh`). |
| 28 | - The Pi is still needed for: certificate renewal, the /var/www publish target, `/rad/` (radicle-httpd) |
| 29 | and Headscale. |
| 30 | |
| 31 | ## 2. Where the data lives |
| 32 | |
| 33 | | data | where | source of truth? | backup | |
| 34 | |---|---|---|---| |
| 35 | | forged state | Spark `~/forge-data/` | `social.log` (when present) is; `archives/`, `collab/`, `search/` are derived caches; `logs/` is the request log; `social.key` is the session HMAC key | `forge-backup` (section 4), without caches, logs and social.key | |
| 36 | | Radicle storage (86 RIDs) | Spark `~/.radicle/storage` | yes for refs; objects are seeded to iris/rosa.radicle.network for public RIDs [INFERENCE: not verified per RID] and the Pi holds a copy of all but 2 RIDs | `forge-backup` archives every `refs/` tree (not objects) | |
| 37 | | Radicle node/delegate key | Spark `~/.radicle/keys` | yes | **none**: never copied by any script here; Drake's open item (section 10) | |
| 38 | | nginx config | Spark `/etc/nginx` (readable parts); Pi `/etc/nginx` | the Spark copy serves; `infra/spark/nginx/` holds the edited files | `forge-backup` (readable files only; `certs/` is root-only and skipped); `/etc/nginx.dist-20261108T114650Z` | |
| 39 | | TLS certificates | Pi acme.sh (root) → Pi `/etc/nginx/certs` → Spark `/etc/nginx/certs` | the Pi | re-issuable; not backed up | |
| 40 | | static site | `/var/www/interplane.io` (Spark and Pi) | Radicle z399yKv… | rebuildable from source | |
| 41 | | Forgejo (atlas) | Spark `~/atlas-forgejo/cipher` (gocryptfs), mounted at `~/atlas-forgejo/data` | yes | `~/.local/bin/forgejo-backup` → `~/atlas-forgejo-backups` (section 9) | |
| 42 | | Vaultwarden | Spark `~/services/vaultwarden/data` | yes | `aien-run-vault-backup` + Mac `com.aien.vault-backup-pull` → Mac `~/Backups/vault-spark/` | |
| 43 | |
| 44 | All backup archives are age-encrypted to the one recipient `age1kj2a3s98qgu9nc7nlxd7npj50ekgqh32jfdp6jg9dgn2v6scrccqus5ec6`. |
| 45 | Its identity lives only on the Mac: `~/.config/atlas-forgejo-backup/recovery.agekey`. Losing the Mac |
| 46 | and that file loses every backup. |
| 47 | |
| 48 | ## 3. Deploy, roll back, renew |
| 49 | |
| 50 | - **forged binary:** the deploy rule in `infra/DEPLOY.md` ("forged binary"): commit, `./run.sh deploy |
| 51 | <commit>`, `pkill -x forged` (the supervisor restarts it), check `/proc/$(pgrep -x forged)/exe`'s sha |
| 52 | against the log line. Roll back = `./run.sh deploy <previous commit>` and the same restart. |
| 53 | - **nginx config (Spark):** the files in `infra/spark/nginx/` are copies of the live ones. To change one: |
| 54 | ``` |
| 55 | sudo cp -a /etc/nginx/sites-enabled/interplane.io /etc/nginx/sites-enabled/interplane.io.bak-$(date -u +%Y%m%dT%H%M%SZ) |
| 56 | sudo install -m 644 infra/spark/nginx/sites-interplane.io /etc/nginx/sites-enabled/interplane.io |
| 57 | sudo nginx -t && sudo systemctl reload nginx # a reload, never a restart |
| 58 | bash infra/smoke.sh # exit 2 = a site page failed: roll back now |
| 59 | ``` |
| 60 | Roll back: copy the `.bak-<UTC>` file back, `sudo nginx -t && sudo systemctl reload nginx`. |
| 61 | - **static site:** publishing is automatic (section 1). Roll back by reverting the commit on the |
| 62 | Radicle main of z399yKv…; the publisher and edge-mirror carry it to the Spark. |
| 63 | - **Certificate renewal:** root's crontab on the Pi runs acme.sh (`30 5,11,17,23 * * *`, Gandi |
| 64 | LiveDNS DNS-01, so it works wherever :443 points). `edge-certs.timer` on the Spark copies |
| 65 | `/etc/nginx/certs` daily at 06:45 and reloads nginx only when something changed. The expiry is shown |
| 66 | on the probe page (section 6). Interplane cert notAfter at the time of writing: 2027-01-02T22:17:34Z. |
| 67 | - Renewal failed / cert under 20 days: `ssh hub sudo crontab -l` (entry present?), `ssh hub sudo |
| 68 | ls -la /root/.acme.sh/` [INFERENCE: root-owned acme.sh home], run the renewal by hand as root on the |
| 69 | Pi (`acme.sh --renew -d interplane.io`), then on the Spark `systemctl --user start edge-certs.service` |
| 70 | and check with `openssl s_client -connect 192.168.1.108:443 -servername interplane.io </dev/null | |
| 71 | openssl x509 -noout -enddate`. |
| 72 | - Gandi token expired: Drake creates a new LiveDNS token in the Gandi panel and puts it in acme.sh's |
| 73 | account config on the Pi (root). Nothing in this repo holds it. |
| 74 | - Expired already: browsers refuse because of HSTS (max-age 1 year, includeSubDomains); there is no |
| 75 | bypass, only renewal. |
| 76 | |
| 77 | ## 4. Backups (forge) |
| 78 | |
| 79 | `infra/ops/forge-backup.sh` writes one archive per change burst: |
| 80 | `~/forge-backups/forge-backup-<UTC>.tar.gz.age` plus `.sha256` and `latest.json`, keeping the newest 60 |
| 81 | (FORGE_BACKUP_KEEP). Contents: `forge-data/` (no caches, logs, *.pid, social.key), `nginx/` (readable |
| 82 | files of /etc/nginx), `storage/<RID>/refs/` and `MANIFEST.txt`. It never reads `~/.radicle/keys` and |
| 83 | refuses (exit 4) if a secret path would enter the archive. Without a valid `FORGE_BACKUP_RECIPIENT` |
| 84 | it refuses (exit 3) before writing anything. An unchanged content digest writes nothing. |
| 85 | |
| 86 | Trigger: `infra/ops/aien-run-forge-backup.service`, `onchange-glob.sh 3600 86400` over `~/forge-data`, |
| 87 | `/etc/nginx`, its subdirs, `~/.radicle/storage`, each RID dir and every dir under each `refs/` |
| 88 | (aien-onchange is not recursive, so the glob wrapper expands the dirs and restarts the watcher when the |
| 89 | set of dirs changes). At most one run per hour (Radicle refs move on every push; a |
| 90 | measured 2026-11-09: 13.6 MB as plain tar, 0.43 MB gzipped, per archive), at least one per day. |
| 91 | |
| 92 | Off-host: the Mac pulls `~/forge-backups` and `~/atlas-forgejo-backups` with |
| 93 | `infra/ops/mac/forge-backup-pull.sh` (launchd `com.aien.forge-backup-pull`) into |
| 94 | `~/Backups/forge-spark/` and `~/Backups/forgejo-spark/`, keeping 120 days. It waits on the Spark with |
| 95 | `inotifywait -e moved_to` (each script renames its finished archive into place), at least once a day |
| 96 | (PULL_MAX_GAP). |
| 97 | |
| 98 | ## 5. Restore |
| 99 | |
| 100 | Identity: the Mac's `~/.config/atlas-forgejo-backup/recovery.agekey`. Decrypt on the Mac, or copy the |
| 101 | identity to the target over ssh into a 0600 file and delete it afterwards. |
| 102 | |
| 103 | ``` |
| 104 | shasum -a 256 -c forge-backup-<UTC>.tar.gz.age.sha256 # Mac (sha256sum -c on Linux) |
| 105 | infra/ops/forge-backup.sh restore forge-backup-<UTC>.tar.gz.age ~/.config/atlas-forgejo-backup/recovery.agekey /tmp/restore-<UTC> |
| 106 | ``` |
| 107 | |
| 108 | `restore` refuses a non-empty target, checks the `.sha256` when present, and reports a wrong identity |
| 109 | as "decryption FAILED". Then, by hand, after reading `MANIFEST.txt`: |
| 110 | |
| 111 | - forge-data: stop forged (`bash infra/spark/forged-service.sh stop`), copy `forge-data/social.log` |
| 112 | (and anything else restored) into `~/forge-data/`, start forged. `social.key` is not in any backup: |
| 113 | forged creates a new one, so every signed-in session ends and users sign in again. Caches refill. |
| 114 | - Radicle refs: the archive holds refs only. Fetch the objects first (`rad sync --fetch <RID>`, from the |
| 115 | seeds or the Pi), then compare `storage/<RID>/refs` with the live tree; copy refs only for RIDs whose |
| 116 | objects are present. Never restore refs over a newer tree without checking `git -C |
| 117 | ~/.radicle/storage/<RID> cat-file -e <sha>` for each ref. |
| 118 | - nginx: diff `nginx/` against `/etc/nginx`, install the needed files with `sudo install`, then |
| 119 | `sudo nginx -t && sudo systemctl reload nginx`. Certificates come from the Pi (`edge-certs`). |
| 120 | |
| 121 | **Drill (dry-run restore into a scratch dir):** run `infra/test/ops-scratch.sh` on the Spark. It makes |
| 122 | a throwaway age key, backs up the live sources into a scratch spool, restores into a scratch dir, |
| 123 | checks that no social.key, keys/ or objects/ came back, and checks that a wrong key and a non-empty |
| 124 | target are refused. For a drill with the real key, do the restore step above on the Mac into |
| 125 | `$(mktemp -d)`, read `MANIFEST.txt`, then delete the dir. Log each drill below. |
| 126 | |
| 127 | Drill log: |
| 128 | - 2026-11-09 (ipl-ops): throwaway key, `infra/test/ops-scratch.sh`; result in |
| 129 | `~/handoffs/hive/forge-next/READY-forge-ops.txt`. |
| 130 | |
| 131 | ## 6. Monitoring: the probe page |
| 132 | |
| 133 | `infra/ops/ipl-uptime-probe.sh` (unit `aien-run-ipl-uptime.service`, `aien-loop 300`: reachability has |
| 134 | no change signal) GETs `/`, `/explore`, `/forge/` and two forge pages by the public name every 5 min |
| 135 | and reads the served certificate's expiry with openssl. `infra/ops/ipl-uptime-render.sh` (unit |
| 136 | `aien-run-ipl-uptime-page.service`, aien-onchange on the state dir) renders |
| 137 | `/var/www/interplane-uptime/index.html`, served at https://interplane.io/status/uptime/. |
| 138 | |
| 139 | **It is an inside view.** The Spark resolves the public address and the router hairpins it back to |
| 140 | the Spark, so it shows that nginx, forged and the cert work, not that the house is reachable from |
| 141 | outside. The page says so and prints no uptime percentage, only counts inside the measured window. |
| 142 | The outside check is Drake's open item 11 (UptimeRobot). |
| 143 | |
| 144 | Install (Drake or the desk; nothing below has been run): |
| 145 | ``` |
| 146 | sudo install -d -o drakestapleton -m 755 /var/www/interplane-uptime |
| 147 | # nginx: deploy infra/spark/nginx/sites-interplane.io from forge/home-root (section 3; routing below) |
| 148 | cp infra/ops/aien-run-ipl-uptime.service infra/ops/aien-run-ipl-uptime-page.service ~/.config/systemd/user/ |
| 149 | systemctl --user daemon-reload |
| 150 | systemctl --user enable --now aien-run-ipl-uptime.service aien-run-ipl-uptime-page.service |
| 151 | ``` |
| 152 | The units run from the live checkout `~/work/forge/web`, so merge first. |
| 153 | |
| 154 | Routing: the vhost locations live in the home-root lane, not in this branch (forge/home-root |
| 155 | 8ba7444, also forge/home-root-on-iplreach 884d3d1, in `infra/spark/nginx/sites-interplane.io` and |
| 156 | `infra/nginx/sites-enabled/interplane.io`, with smoke.sh and edge-local.sh checks). There |
| 157 | `location = /status/uptime` (301 to the slash) and `location ^~ /status/uptime/` (alias |
| 158 | `/var/www/interplane-uptime/`) are carved out ahead of the `/status/` 301 to /protocol/status/: an |
| 159 | exact or `^~` prefix match stops nginx from trying the regex locations, so neither that 301 nor |
| 160 | forged takes the page, and a missing page is a plain 404. Until forge/home-root is merged and its |
| 161 | vhost deployed, /status/uptime/ goes to forged. This branch does not touch the vhost (two copies |
| 162 | would fail nginx -t with a duplicate location). infra/test/ops-scratch.sh section 4 tests the vhost |
| 163 | of the tree it runs in on a throwaway nginx (root and static folders from disk, other paths to |
| 164 | forged, /status/uptime/ to forged while the location is absent); section 4b serves the page through |
| 165 | another ref's vhost when `IPL_TEST_VHOST_REF=forge/home-root` is set, and is NOT_RUN otherwise. |
| 166 | |
| 167 | ## 7. Clock timers and their replacements (RULE-no-cron) |
| 168 | |
| 169 | | timer | replacement in this repo | status | |
| 170 | |---|---|---| |
| 171 | | `atlas-forgejo-backup.timer` (nightly) | `infra/spark/aien-run-forgejo-backup.service`: onchange-glob 21600 86400 on the Forgejo refs dirs, `ExecCondition=mountpoint -q ~/atlas-forgejo/data` | written, not installed. Install only after Forgejo is back (section 9), then `systemctl --user disable --now atlas-forgejo-backup.timer` | |
| 172 | | `edge-mirror.timer` (every 5 min) | `infra/spark/edge-mirror-onchange.service`: aien-onchange 60 86400 on `~/.local/share/interplane-site` (published.cksum and sync.log, written by sync-to-hub.sh on every interplane.io publish) | partial: covers interplane.io only. The other folders (aienos.com, aienos-code, aienos-hive, aienos-stats, replicate, si) have no change signal on the Spark, so **the timer stays** until their publishers write to the Spark directly (README-edge "Next"). Both may run: `edge-mirror.sh` now takes a lock and waits | |
| 173 | | `edge-certs.timer` (daily) | none | **timer stays.** The certs change on the Pi, which has no inotify-tools, and acme.sh runs from root's crontab there; no signal crosses to the Spark. Options for Drake: an acme.sh `--reloadcmd` on the Pi that touches a file the Spark watches over ssh, or `apt install inotify-tools` on the Pi | |
| 174 | |
| 175 | Live timers were not disabled by this work. |
| 176 | |
| 177 | ## 8. When something is down |
| 178 | |
| 179 | Start with `bash infra/smoke.sh` (public) and `bash infra/smoke.sh local` (forged direct): exit 2 = a |
| 180 | site page failed, exit 1 = only forge routes failed. |
| 181 | |
| 182 | - **forged down** (forge paths 502, static pages fine): `tmux ls | grep forged`; |
| 183 | `bash infra/spark/forged-service.sh status`; restart with `bash infra/spark/forged-service.sh start`; |
| 184 | log `~/forge-data/logs/forged.log`. A bad binary: deploy the previous commit (section 3). Static pages |
| 185 | keep working meanwhile. |
| 186 | - **Pi down:** interplane.io keeps serving (the Spark has the certs and a mirror). Lost: new publishes |
| 187 | (they target the Pi), `/rad/` (502), certificate renewal (the Spark keeps the last certs; there are |
| 188 | weeks of margin, check the probe page), Headscale (hs.aienos.com and the tailnet coordination). |
| 189 | Fix the Pi; if it is gone for good, see README-edge "Next" (publish to the Spark directly, run |
| 190 | radicle-httpd on the Spark, move acme.sh with the Gandi token). |
| 191 | - **Spark down:** everything public is down, including hs.aienos.com from outside (its TCP passes |
| 192 | through the Spark). Fallback while the Spark is out: on the router point TCP 443 back to |
| 193 | 192.168.1.192 (README-edge "Undo"); the Pi still has the hub-era nginx config and the static sites, |
| 194 | but forge paths fail there unless forged runs somewhere (forged-tunnel). Point it back to .108 when |
| 195 | the Spark returns. |
| 196 | - **Router / WAN down:** nothing to do on the hosts; the probe page will still show green (inside |
| 197 | view). An outside monitor is item 11. |
| 198 | - **Disk full on the Spark:** forge-backup keeps 60 archives (under 1 MB each today); the Forgejo |
| 199 | backup keeps 30 (about 520 MB each). nginx spools downloads under /var/lib/nginx/proxy. |
| 200 | |
| 201 | ## 9. Forgejo (atlas) outage, since 2026-11-08 |
| 202 | |
| 203 | Evidence and root cause: `infra/spark/forgejo/EVIDENCE-20261109.txt`. Short form: the Forgejo and |
| 204 | gocryptfs binaries were deleted with the archived setup dir on 2026-11-08; the nightly backup stopped |
| 205 | Forgejo, which then could not restart; the storage unit restart-loops on 203/EXEC. The encrypted data |
| 206 | (`~/atlas-forgejo/cipher`) and the Nov 6 and Nov 7 backups are intact. |
| 207 | |
| 208 | **Decision for Drake: restore or retire.** |
| 209 | |
| 210 | Restore (needs root for the last step): |
| 211 | ``` |
| 212 | bash infra/spark/forgejo/forgejo-runtime-restore.sh --dry-run # verifies sha, signature, versions into a scratch dir |
| 213 | bash infra/spark/forgejo/forgejo-runtime-restore.sh --apply # stages ~/.local/opt/atlas-forgejo-runtime-20260904, repoints the symlink |
| 214 | install -m 755 infra/spark/forgejo/forgejo-backup ~/.local/bin/forgejo-backup # the patched script (see forgejo-backup.patch) |
| 215 | ~/.local/bin/forgejo-backup --dry-run # must print "ok" for both binaries |
| 216 | sudo systemctl reset-failed atlas-forgejo-storage.service atlas-forgejo.service |
| 217 | sudo systemctl start atlas-forgejo-storage.service atlas-forgejo.service |
| 218 | curl -sk https://127.0.0.1:3443/api/healthz |
| 219 | # on the Mac, after the pull: forgejo-backup verify <archive> ~/.config/atlas-forgejo-backup/recovery.agekey |
| 220 | ``` |
| 221 | Roll back the runtime: `ln -sfn "$(cat ~/.local/opt/atlas-forgejo-runtime-20260904/previous-symlink-target)" ~/atlas-forgejo-setup-20260904`. |
| 222 | Roll back the script: `patch -R ~/.local/bin/forgejo-backup infra/spark/forgejo/forgejo-backup.patch`. |
| 223 | After it runs: install `infra/spark/aien-run-forgejo-backup.service` and disable the timer (section 7). |
| 224 | |
| 225 | Retire: `sudo systemctl disable --now atlas-forgejo-storage.service atlas-forgejo.service`, |
| 226 | `systemctl --user disable --now atlas-forgejo-backup.timer`, keep `~/atlas-forgejo/cipher` and the |
| 227 | last two archives (both also pulled to the Mac once the pull is installed) until Drake says otherwise. |
| 228 | |
| 229 | ## 10. Drake's open items (ops proposal parts b and c) |
| 230 | |
| 231 | Install (part a, written here, nothing enabled): |
| 232 | 1. `/var/www/interplane-uptime`, the nginx vhost from forge/home-root and the two probe units (section 6). |
| 233 | 2. `cp infra/ops/aien-run-forge-backup.service ~/.config/systemd/user/ && systemctl --user daemon-reload && systemctl --user enable --now aien-run-forge-backup.service`. |
| 234 | 3. Mac: `cp infra/ops/mac/forge-backup-pull.sh ~/.local/bin/ && cp infra/ops/mac/com.aien.forge-backup-pull.plist ~/Library/LaunchAgents/ && launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.aien.forge-backup-pull.plist`. |
| 235 | 4. `edge-mirror-onchange.service` (section 7) and the Forgejo decision (section 9). |
| 236 | 5. Radicle delegate key: decide whether `~/.radicle/keys` gets an encrypted off-host copy. Today it has |
| 237 | none, and this work does not copy it. |
| 238 | |
| 239 | At Gandi (Drake; the acme.sh token on the Pi is not authorized for these): |
| 240 | 6. Mail: a mailbox, or a forward of `hello@` and `security@` to an existing address. |
| 241 | 7. SPF: `?all` → `~all`, then `-all` once mail is confirmed; or `v=spf1 -all` and no MX if no mail. |
| 242 | 8. DMARC: `_dmarc TXT "v=DMARC1; p=none; rua=mailto:<addr from 6>"`, `p=quarantine` after 2 clean weeks. |
| 243 | 9. CAA: `0 issue "letsencrypt.org"` and `0 iodef "mailto:security@interplane.io"`. |
| 244 | 10. Registrar: auto-renew, transfer lock, 2FA, the domain expiry date. Record here who holds the Gandi |
| 245 | login and where the 2FA device is. |
| 246 | |
| 247 | Outside check: |
| 248 | 11. UptimeRobot free plan (no card): HTTPS keyword monitors for `https://interplane.io/` and `/forge/` |
| 249 | (`https://www.aienos.com/forge/` only redirects to interplane.io since 2026-11-10; a monitor on it |
| 250 | should expect 301), alerts to the address from item 6. Without an account: manual |
| 251 | check-host.net runs only. Inside probes do not count as outside. |
| 252 | |
| 253 | Router (Drake, Calix): reserve 192.168.1.108 for the Spark (MAC 4c:bb:47:2b:b8:7b) and, when the |
| 254 | :80→301 change is merged, forward TCP 80 to .108. Record the router admin login location here. |
| 255 | |
| 256 | Alerts: none exist. Until items 6 and 11 are done, a failure is seen only on the probe page, the |
| 257 | journal (`journalctl --user -u <unit>`), and the BOARD. |