interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / infra / RUNBOOK.md

257 lines · 19521 bytes Raw Blame History Rendered
1# interplane.io and the forge: operations runbook
2
3Scope: the public site interplane.io (static pages plus forged) and the redirect from www.aienos.com/forge/ (since 2026-11-10), served from
4the Spark since 2026-11-08. Deploy details live in `infra/DEPLOY.md` (written for the hub-era edge;
5the same scripts and rules apply) and the front-door switch in `infra/spark/README-edge.md`. This file
6covers running it: where the data is, how to renew, back up, restore, and what to do when a host is
7down. Hosts: the Spark (`ssh spark`, LAN 192.168.1.108), the hub Pi (`ssh hub`, 192.168.1.192), the
8operator Mac. Router: Calix at https://192.168.1.1.
9
10## 1. Serving path
11
12```
13client ─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
21forged: 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
44All backup archives are age-encrypted to the one recipient `age1kj2a3s98qgu9nc7nlxd7npj50ekgqh32jfdp6jg9dgn2v6scrccqus5ec6`.
45Its identity lives only on the Mac: `~/.config/atlas-forgejo-backup/recovery.agekey`. Losing the Mac
46and 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
82files of /etc/nginx), `storage/<RID>/refs/` and `MANIFEST.txt`. It never reads `~/.radicle/keys` and
83refuses (exit 4) if a secret path would enter the archive. Without a valid `FORGE_BACKUP_RECIPIENT`
84it refuses (exit 3) before writing anything. An unchanged content digest writes nothing.
85
86Trigger: `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
89set of dirs changes). At most one run per hour (Radicle refs move on every push; a
90measured 2026-11-09: 13.6 MB as plain tar, 0.43 MB gzipped, per archive), at least one per day.
91
92Off-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
100Identity: the Mac's `~/.config/atlas-forgejo-backup/recovery.agekey`. Decrypt on the Mac, or copy the
101identity to the target over ssh into a 0600 file and delete it afterwards.
102
103```
104shasum -a 256 -c forge-backup-<UTC>.tar.gz.age.sha256 # Mac (sha256sum -c on Linux)
105infra/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
109as "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
122a throwaway age key, backs up the live sources into a scratch spool, restores into a scratch dir,
123checks that no social.key, keys/ or objects/ came back, and checks that a wrong key and a non-empty
124target 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
127Drill 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
134no change signal) GETs `/`, `/explore`, `/forge/` and two forge pages by the public name every 5 min
135and 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
140the Spark, so it shows that nginx, forged and the cert work, not that the house is reachable from
141outside. The page says so and prints no uptime percentage, only counts inside the measured window.
142The outside check is Drake's open item 11 (UptimeRobot).
143
144Install (Drake or the desk; nothing below has been run):
145```
146sudo 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)
148cp infra/ops/aien-run-ipl-uptime.service infra/ops/aien-run-ipl-uptime-page.service ~/.config/systemd/user/
149systemctl --user daemon-reload
150systemctl --user enable --now aien-run-ipl-uptime.service aien-run-ipl-uptime-page.service
151```
152The units run from the live checkout `~/work/forge/web`, so merge first.
153
154Routing: the vhost locations live in the home-root lane, not in this branch (forge/home-root
1558ba7444, 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
159exact or `^~` prefix match stops nginx from trying the regex locations, so neither that 301 nor
160forged takes the page, and a missing page is a plain 404. Until forge/home-root is merged and its
161vhost deployed, /status/uptime/ goes to forged. This branch does not touch the vhost (two copies
162would fail nginx -t with a duplicate location). infra/test/ops-scratch.sh section 4 tests the vhost
163of the tree it runs in on a throwaway nginx (root and static folders from disk, other paths to
164forged, /status/uptime/ to forged while the location is absent); section 4b serves the page through
165another 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
175Live timers were not disabled by this work.
176
177## 8. When something is down
178
179Start with `bash infra/smoke.sh` (public) and `bash infra/smoke.sh local` (forged direct): exit 2 = a
180site 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
203Evidence and root cause: `infra/spark/forgejo/EVIDENCE-20261109.txt`. Short form: the Forgejo and
204gocryptfs binaries were deleted with the archived setup dir on 2026-11-08; the nightly backup stopped
205Forgejo, 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
210Restore (needs root for the last step):
211```
212bash infra/spark/forgejo/forgejo-runtime-restore.sh --dry-run # verifies sha, signature, versions into a scratch dir
213bash infra/spark/forgejo/forgejo-runtime-restore.sh --apply # stages ~/.local/opt/atlas-forgejo-runtime-20260904, repoints the symlink
214install -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
216sudo systemctl reset-failed atlas-forgejo-storage.service atlas-forgejo.service
217sudo systemctl start atlas-forgejo-storage.service atlas-forgejo.service
218curl -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```
221Roll back the runtime: `ln -sfn "$(cat ~/.local/opt/atlas-forgejo-runtime-20260904/previous-symlink-target)" ~/atlas-forgejo-setup-20260904`.
222Roll back the script: `patch -R ~/.local/bin/forgejo-backup infra/spark/forgejo/forgejo-backup.patch`.
223After it runs: install `infra/spark/aien-run-forgejo-backup.service` and disable the timer (section 7).
224
225Retire: `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
227last 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
231Install (part a, written here, nothing enabled):
2321. `/var/www/interplane-uptime`, the nginx vhost from forge/home-root and the two probe units (section 6).
2332. `cp infra/ops/aien-run-forge-backup.service ~/.config/systemd/user/ && systemctl --user daemon-reload && systemctl --user enable --now aien-run-forge-backup.service`.
2343. 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`.
2354. `edge-mirror-onchange.service` (section 7) and the Forgejo decision (section 9).
2365. 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
239At Gandi (Drake; the acme.sh token on the Pi is not authorized for these):
2406. Mail: a mailbox, or a forward of `hello@` and `security@` to an existing address.
2417. SPF: `?all` → `~all`, then `-all` once mail is confirmed; or `v=spf1 -all` and no MX if no mail.
2428. DMARC: `_dmarc TXT "v=DMARC1; p=none; rua=mailto:<addr from 6>"`, `p=quarantine` after 2 clean weeks.
2439. CAA: `0 issue "letsencrypt.org"` and `0 iodef "mailto:security@interplane.io"`.
24410. 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
247Outside check:
24811. 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
253Router (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
256Alerts: none exist. Until items 6 and 11 are done, a failure is seen only on the probe page, the
257journal (`journalctl --user -u <unit>`), and the BOARD.