Docs: server agent and Hub 2.1.0 plan (phase 1d, decisions 27-37)
Agent on every server runs installs, scheduled/emergency updates and uninstalls on signed jobs from the Hub, polls only (no listening port), appends to frpc.ini in marked blocks, builds .env files from per-server config in the Hub. FastPanel and DNS stay manual (emailed instructions). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+69
-8
@@ -20,6 +20,12 @@ updates"), the Hub tracks releases per product (§5), and the contracts reach th
|
||||
committed to its repo instead of through a package registry (§2). Cross Events versions in §9
|
||||
moved up by one (the move is 2.2.0). See decisions 21–24.
|
||||
|
||||
**Updated 2026-11-12:** a **server agent** on each server installs, updates and uninstalls
|
||||
church sites on signed jobs from the Hub (phase 1d, [AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md)).
|
||||
The Hub can now trigger changes, but no site depends on it to keep running and the agent only
|
||||
polls (it has no URL or open port). Rule 2 (§1), §5, §8 and §9 are updated; decisions 27–37
|
||||
change decisions 10 and 23.
|
||||
|
||||
---
|
||||
|
||||
## Contents
|
||||
@@ -61,8 +67,10 @@ own process and its own database. The Hub only sees aggregate stats and licences
|
||||
**Rules**
|
||||
|
||||
1. **No shared databases, ever.** Products only talk over HTTPS using documented contracts (§2).
|
||||
2. **The Hub is never on the runtime path.** It stays read-only toward installs: installs push to
|
||||
it, it never reaches into them, and a Hub outage switches nobody off.
|
||||
2. **The Hub is never on the runtime path.** Installs push to it, it never connects to them, and
|
||||
a Hub outage switches nobody off. **Changes to a site are made by the server agent** on its
|
||||
server (from phase 1d): it polls the Hub for **signed jobs of fixed types**, only ever runs the
|
||||
`crosscode` script, and has no URL or listening port of its own (§8, decisions 27–37).
|
||||
3. **One maintained codebase per product.** Each church runs a tagged release of it. Nothing is
|
||||
built specially for one church.
|
||||
4. **The origin of a record owns it.** Copies elsewhere are read-only and link back to the origin.
|
||||
@@ -317,7 +325,14 @@ product's customers, licences, stats, AI usage and billing.
|
||||
before it deploys (§8). By default products never need to update together: the contract rules
|
||||
(§2) and protocol v1 + v2 make that possible, so requirements are only for real breaking moves
|
||||
such as Events 3.0.
|
||||
- **Request update** works for every product. The Hub still never runs anything on an install.
|
||||
- **Request update** works for every product. From Hub 2.1.0 Joshua answers it with a
|
||||
**scheduled update** (at least 4 hours' notice to the site admin, emergency at least 15
|
||||
minutes), carried out by the server agent (§8).
|
||||
- **Servers (Hub 2.1.0):** every server's agent, its stats (RAM, CPU, disk, spikes, PM2
|
||||
processes per church), alerts, the frp port list, server configuration (database and other
|
||||
per-server `.env` values, stored encrypted), new installs with a choice of server, jobs with
|
||||
emailed reports, and uninstalls with a 30-day encrypted export for the church
|
||||
([AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md)).
|
||||
- **Domain:** `hub.crosscode.co.za`. `events-hub.crosscode.co.za` stays as an alias so existing
|
||||
installs keep working.
|
||||
- Dashboard: installs per product, versions behind latest, health, licence status, monthly
|
||||
@@ -463,7 +478,7 @@ browsed without an account. Personal actions need sign-in through Accounts.
|
||||
|
||||
| Repo | What |
|
||||
|------|------|
|
||||
| `joshua/crosscode-platform` | **Every product a church installs**, and what they share: `apps/events` (Cross Events, moved here in 2.2.0), `apps/accounts`, `apps/website`, `apps/app`, `packages/contracts`, `packages/ui`, `packages/seo` (§11), and the `crosscode` script (`scripts/`) |
|
||||
| `joshua/crosscode-platform` | **Every product a church installs**, and what they share: `apps/events` (Cross Events, moved here in 2.2.0), `apps/accounts`, `apps/website`, `apps/app`, `packages/contracts`, `packages/ui`, `packages/seo` (§11), the `crosscode` script (`scripts/`) and the server agent (`apps/agent`, phase 1d) |
|
||||
| `joshua/hope-events` | Cross Events up to 2.1.x. **Archived** after the move (read-only, README points to the monorepo), and kept so installs that haven't moved yet can still deploy or roll back a `v2.1.x` tag |
|
||||
| `joshua/events-hub` | Cross Code Hub (renamed in the UI; repo name can stay). Stays on its own: it runs on its own server, is never installed for a church, and is deployed with its own `scripts/deploy.sh`. Gets the contracts as a committed file (§2) |
|
||||
| `joshua/crosscode-site` | The marketing site (crosscode.co.za). Updated at the end of every phase that changes what's on sale or what a product does (see §9, "Updating crosscode-site") |
|
||||
@@ -473,8 +488,10 @@ Playwright, Jest), so code and habits carry over.
|
||||
|
||||
### Releases and updates
|
||||
|
||||
**What doesn't change:** git is how code reaches a server, the Hub only records releases and
|
||||
passes on update requests (it never deploys, §1 rule 2), and Joshua runs the deploys.
|
||||
**What doesn't change:** git is how code reaches a server, and every install, update and
|
||||
uninstall goes through the `crosscode` script. Until phase 1d Joshua runs it by hand; from
|
||||
phase 1d the **server agent** runs it on signed jobs from the Hub (below), and it still works by
|
||||
hand over SSH.
|
||||
|
||||
**Releasing.** Each product is tagged on its own in the monorepo: `events@2.2.0`,
|
||||
`accounts@1.0.0`, `website@1.0.0`, `app@1.0.0` (and `contracts@1.0.0`, which nobody installs).
|
||||
@@ -564,6 +581,30 @@ would be down for the whole build. The steps are in
|
||||
The PM2 names, nginx config (it only proxies to ports), database and its name stay the same.
|
||||
Installs that haven't moved yet keep working with `deploy.sh` on the archived repo.
|
||||
|
||||
### Server agent (phase 1d)
|
||||
|
||||
Planned in [AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md). In short:
|
||||
|
||||
- **`crosscode-agent`** (`apps/agent`, systemd) on every church server. It **only polls** the Hub
|
||||
(outgoing HTTPS; no URL, no listening port), sends server stats every minute, and runs
|
||||
**signed jobs of fixed types** (install, add product, deploy, adopt, restart, export,
|
||||
uninstall), each by calling the `crosscode` script. Uninstall and emergency updates need 2FA
|
||||
again in the Hub.
|
||||
- **Servers are behind frp** to one central FastPanel server. The Hub hands out the tunnel ports
|
||||
(unique across all servers). The agent **only appends** marked blocks to `/etc/frp/frpc.ini` and
|
||||
removes only its own blocks. A read-only agent on the central server checks the ports are open
|
||||
and only bound to `127.0.0.1`. **FastPanel and DNS are never automated:** Joshua gets an email
|
||||
with what to set up.
|
||||
- **`.env` files** are built from a per-product template: database and other server values set
|
||||
**once per server in the Hub** (sent encrypted), platform defaults, the install's domain and
|
||||
ports, and secrets generated on the server (never sent anywhere). Updates only append new
|
||||
variables.
|
||||
- **Updates** are scheduled at least 4 hours ahead (emergency 15 minutes) with an email and banner
|
||||
to the site admin, and run one install at a time. **Uninstall** gives the church a JSON export
|
||||
in our own format (encrypted, 30 days) and keeps backups for 30 days.
|
||||
- New `crosscode` commands for it: `uninstall`, `export`, `purge`, `restart`, and `--json`
|
||||
reports on every command.
|
||||
|
||||
---
|
||||
|
||||
## 9. Build order
|
||||
@@ -574,6 +615,7 @@ Installs that haven't moved yet keep working with `deploy.sh` on the archived re
|
||||
| 1 | **Hub 2.0.0** | Cross Code Hub: products, licence per product, per-customer billing with bundles, protocol v2 (v1 still accepted), sibling discovery, AI usage per product, **releases per product with requirements** (§5), contracts as a committed file (§2). **Released 2026-11-05** (crosscode-site address prices merged) | Must exist before a second product is sold, and before Events releases come from the monorepo |
|
||||
| 1b | **Cross Events 2.2.0** | **Moves into the monorepo** as `apps/events`, with its git history (merged in, not copied); its packages become workspaces; the **`crosscode` script** (`deploy`, `status`, `install`, `adopt`; §8) replaces `scripts/deploy.sh` and `scripts/install.sh`; every install moved with `crosscode adopt`; `hope-events` archived. No feature changes, so a problem is clearly the move | Before more products, so every product is released and deployed the same way from the start |
|
||||
| 1c | **Cross Events 2.3.0** | **Authenticator app 2FA** (TOTP) next to email and WhatsApp, with recovery codes; admins can see which method each staff account uses | Independent and useful now; the Accounts migration later carries it over |
|
||||
| 1d | **Agent 1.0.0 + Hub 2.1.0** (contracts 1.2.0) | **Server agent** on every server (polls only, signed jobs, runs the `crosscode` script); Hub: Servers page with stats and alerts, server configuration, frp port list, New install with a choice of server, scheduled / emergency / batch updates with notice to the church, uninstall with an encrypted JSON export, emailed reports. [AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md) | Right after 1b (it runs the `crosscode` script), so every new church from then on is installed from the Hub. Can run alongside 1c |
|
||||
| 2 | **Cross Events 2.4.0** | Reports `product: "events"` (protocol v2), **Linked products**, the event feed (publish + show events from siblings), `packages/seo` (§11) with canonical links for imported events | Small; ready for when the Website exists |
|
||||
| 3 | **Accounts 1.0.0** | OIDC provider, sign-in, 2FA (email, WhatsApp, authenticator app), password reset, consent and notice, export / delete fan-out, admin, install script | The Website is built on it from day one |
|
||||
| 4 | **Church Website 1.0.0** | Public site with the **four templates** (§6), admin, simple events + feed, SEO (§11), Hope Family Church as the first church, then a second test church on a different template to prove it repeats | More churches need a website than an app; it also covers the "website only" case |
|
||||
@@ -596,6 +638,7 @@ At the end of each phase, update it in the same sitting and deploy it (its `DEPL
|
||||
| 1 Hub 2.0.0 | Bundle discounts (15% / 25%) and the address add-on (own domain R0 · Cross Code address R10 · domain included R25) in `src/data/pricing.mjs`, worded so it's clear the Website and App are still coming. Legal pages if billing terms change |
|
||||
| 1b Events 2.2.0 | Nothing (the move doesn't change what Cross Events does) |
|
||||
| 1c Events 2.3.0 | Authenticator app 2FA in the Cross Events feature list (`src/data/cross-events.mjs`) and the security / POPIA wording |
|
||||
| 1d Agent 1.0.0 + Hub 2.1.0 | Nothing (it changes how installs are run, not what churches buy) |
|
||||
| 2 Events 2.4.0 | "Works with the Church Website and App" (event feed, Linked products) on the Cross Events page, as "coming" until those ship |
|
||||
| 3 Accounts 1.0.0 | "One sign-in for all your church's products" on the Products page. Accounts isn't sold, so no page or price of its own |
|
||||
| 4 Website 1.0.0 | **Church Website goes on sale:** `status: "available"` and its own page in `src/data/products.mjs` / `src/pages/products/`, R99 + storage add-on in `pricing.mjs`, **a showcase of the four templates** (a page per template with screenshots of the same demo church in each), screenshots from a demo church (fictional people only), FAQ, home page, contact form product list, `SoftwareApplication` JSON-LD (§11) |
|
||||
@@ -620,6 +663,8 @@ Hub never disagree. Run the site's tests and build before deploying it.
|
||||
- crosscode-site shows the product as available, with its page, prices and screenshots.
|
||||
- The §11 SEO checks pass (Playwright and Lighthouse), for the Website in all four templates.
|
||||
- A database backup is restored successfully.
|
||||
- (From phase 1d) The product installs, updates and uninstalls through the server agent from the
|
||||
Hub, with its `.env` template complete and its uninstall export in `crosscode.church-export/1`.
|
||||
|
||||
---
|
||||
|
||||
@@ -757,7 +802,7 @@ ranking.
|
||||
| 7 | Hub | Becomes **Cross Code Hub**: every product's licences, stats, AI and billing in one place, still read-only toward installs |
|
||||
| 8 | Stack | Next.js + Express + Prisma + PostgreSQL + pg-boss, as Cross Events (not the specs' React + Vite, Redis + BullMQ, Socket.IO) |
|
||||
| 9 | Pricing | Income bands per product, bundles 15% (two) / 25% (three); every App module for every church (not the website spec's Starter / Growth / Pro tiers) |
|
||||
| 10 | Hub provisioning | Scripts Joshua runs; the Hub records installs but never deploys or rolls back (not the specs' automated provisioning) |
|
||||
| 10 | Hub provisioning | Scripts Joshua runs; the Hub records installs but never deploys or rolls back (not the specs' automated provisioning). **Changed 2026-11-12** by decisions 27–37: the server agent runs the script on signed jobs from the Hub |
|
||||
| 11 | Installs per product | **One install of each product per customer**; the Hub refuses a second licence for the same product |
|
||||
| 12 | House of Prayer defaults | 1-hour slots, book up to 12 months ahead, recurring bookings for up to 12 months from the day of booking, no cancelling within 8 hours of the slot |
|
||||
| 13 | App notifications | **Email and WhatsApp only.** No push notifications |
|
||||
@@ -775,7 +820,7 @@ ranking.
|
||||
|---|----------|----------|
|
||||
| 21 | Repos | **Cross Events moves into `crosscode-platform`** (`apps/events`, Events 2.2.0, history kept); `hope-events` is archived. The Hub stays in its own repo (own server, never installed for a church) |
|
||||
| 22 | Contracts for the Hub | A packed release **committed to the Hub's repo** (`file:vendor/…`), not Gitea's package registry, so no deploy depends on a registry or a token (§2) |
|
||||
| 23 | Deploying | **One `crosscode` script** for every product, with every church under `/var/www/sites/<church>/<product>`: `crosscode deploy <church> [events] [website] [app]` always updates Accounts and then the products named, in a fixed order, each rolled back on its own if it fails. Still git checkouts of tags, still run by Joshua; the Hub never deploys (§8) |
|
||||
| 23 | Deploying | **One `crosscode` script** for every product, with every church under `/var/www/sites/<church>/<product>`: `crosscode deploy <church> [events] [website] [app]` always updates Accounts and then the products named, in a fixed order, each rolled back on its own if it fails. Still git checkouts of tags, still run by Joshua; the Hub never deploys (§8). **Changed 2026-11-12** by decision 27: from phase 1d the server agent runs it on jobs from the Hub |
|
||||
| 24 | Product requirements | A release can require a minimum version of a sibling (`— requires accounts 1.2.0` in `WHATS-NEW.md`). The Hub **disables Request update** until it's met, and the script refuses to deploy without it (§5, §8) |
|
||||
|
||||
**Added 2026-11-05**
|
||||
@@ -785,6 +830,22 @@ ranking.
|
||||
| 25 | Moving existing Events installs | `crosscode adopt` **builds the new checkout next to the running install and switches PM2 over** (seconds of downtime) instead of moving the running folder; the old folder is untouched, so a failure just starts it again (§8) |
|
||||
| 26 | Undoing a move | **`crosscode adopt <church> --undo`** goes back to the old folder and its 2.1.x while it's kept (14 days) (§8) |
|
||||
|
||||
**Added 2026-11-12** (phase 1d, [AGENT-1.0-PLAN.md](./AGENT-1.0-PLAN.md))
|
||||
|
||||
| # | Question | Decision |
|
||||
|---|----------|----------|
|
||||
| 27 | Deploying from the Hub | A **server agent** on every server runs installs, updates and uninstalls on **signed jobs of fixed types** from the Hub, always through the `crosscode` script (which still works by hand). Changes decisions 10 and 23; rule 2 (§1) reworded |
|
||||
| 28 | The agent's exposure | **It has no URL or listening port.** It only polls the Hub over outgoing HTTPS |
|
||||
| 29 | Confirming risky jobs | Uninstall and emergency updates need **2FA again** in the Hub; uninstall also needs the short name typed |
|
||||
| 30 | Notice before updates | **Scheduled: at least 4 hours**; **emergency: at least 15 minutes**, with a reason. The site admin gets an email and a banner straight away. Joshua picks the time. A job the agent misses doesn't run late |
|
||||
| 31 | Uninstall | The church gets a **JSON export in our own format** (`crosscode.church-export/1`, no internal tables or ids), encrypted so the Hub can't read it, downloadable for **30 days**. The final backup is kept 30 days, then deleted (Joshua emailed 3 days before) |
|
||||
| 32 | frp | Every church server is behind frp to **one central FastPanel server**. The Hub keeps the **port list** (unique across servers, same number local and remote), tunnels are named `<church>-<product>-web/-api` |
|
||||
| 33 | frpc.ini | **Only appended to**, in marked blocks, checked with `frpc verify`, with a backup first; uninstall removes only its own block. `admin_addr = 127.0.0.1` / `admin_port = 7400` added once to `[common]` so frpc reloads without dropping other sites |
|
||||
| 34 | FastPanel and DNS | **Never automated.** Joshua gets an email with the proxy rules, Let's Encrypt and DNS to set up, then clicks *Proxy done*; the Hub checks the public URLs |
|
||||
| 35 | Central server | A **read-only** agent on the central server checks the ports are allowed and open and that frps binds tunnels to `127.0.0.1` (`proxy_bind_addr`). It changes nothing there |
|
||||
| 36 | `.env` configuration | **Database and other server values are set once per server in the Hub**, stored encrypted and sent encrypted to that server's agent with each job. `.env` files come from a per-product template; updates only append new variables; secrets are generated on the server and never leave it |
|
||||
| 37 | Server stats | Every agent reports RAM, CPU, disk and PM2 processes every minute; the Hub keeps minutes for 7 days and hours for 90 days, shows spikes, and emails alerts |
|
||||
|
||||
## Still open
|
||||
|
||||
Nothing. crosscode-site is updated at the end of each phase (§9, "Updating crosscode-site"); the
|
||||
|
||||
Reference in New Issue
Block a user