Docs: Hub 2.0.0 released (phase 1); hub-protocol.md with protocol v2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 09:10:33 +02:00
co-authored by Claude Opus 5.5
parent 9dc2fa8af4
commit 015495ab56
3 changed files with 55 additions and 15 deletions
+42 -5
View File
@@ -1,9 +1,13 @@
# Hub protocol (version 1)
# Hub protocol (versions 1 and 2)
The contract between a **Cross Events install** (the church's site) and the **Cross Events
Hub** (`events-hub.crosscode.co.za`). A copy of this file lives in both repositories
(`joshua/hope-events` → `docs/hub-protocol.md`, `joshua/events-hub` → `docs/hub-protocol.md`);
change both together.
The contract between an **install** (one of a church's products: Cross Events, Accounts, Church
Website, Church App) and **Cross Code Hub** (`hub.crosscode.co.za`; `events-hub.crosscode.co.za`
keeps working as an alias). Sections 1–5 describe **version 1**, which Cross Events 2.1 speaks;
**[version 2](#6-protocol-version-2-hub-20)** (every product, Hub 2.0) is section 6. A copy of this
file lives in both repositories (`joshua/hope-events` → `docs/hub-protocol.md`,
`joshua/events-hub` → `docs/hub-protocol.md`); change both together. From Hub 2.0 the formats are
defined once, in `@crosscode/contracts` (`crosscode-platform/packages/contracts`, `src/hub.ts`,
with JSON Schema and samples).
Principles:
@@ -288,3 +292,36 @@ grace starts). Blocking the Hub can't keep a suspended licence active for more t
fields to a heartbeat or a token doesn't need a new version — both sides ignore fields they
don't know.
- The Hub accepts protocol `N` and `N-1`; anything else is `400 UNSUPPORTED_PROTOCOL`.
## 6. Protocol version 2 (Hub 2.0)
The formats are in `@crosscode/contracts` (`hub.registerRequestSchema`, `hub.heartbeatRequestSchema`,
… with JSON Schema in `schemas/hub-*.json` and samples in `samples/hub-*.json`). The Hub accepts
versions 1 and 2 (`/api/public-key` lists `[1, 2]`); a v1 request is treated as Cross Events and
answered exactly as in sections 1–5. Signing, offline licence checks, update requests and AI calls
are as in version 1.
What version 2 changes:
| | Version 1 | Version 2 |
|---|---|---|
| Who | Cross Events | Every product: `product` is `events`, `accounts`, `website` or `app` |
| Licence keys | `CEH-…` | `CEH-` Events, `CCA-` Accounts, `CCW-` Website, `CCP-` App |
| Register | as §2 | adds `product` (must match the licence: `409 WRONG_PRODUCT`) and `install.publicKey` (the install's Ed25519 public key, PEM) |
| Heartbeat | as §3 | adds `product` (must match the install: `409 WRONG_PRODUCT`); `stats` per product (Events as v1; Website: pages, messages, events, editors, `storage`; App: `activeMembers90d` band, modules, prayer coverage; Accounts: accounts, 2FA methods) |
| Replies | as §2, §3 | add `linkedProducts`: the church's other installs in use that have a public key, as `{ product, installId, url, publicKey }`, nothing else. Releases carry `requires` (below) |
| Bodies | checked by hand | checked against the contract schemas: `400 INVALID_REQUEST` with the field that's wrong; unknown fields are dropped |
| Licence token | as §4 | also `customerId` and `product` (still `v: 1`; a v1 install ignores them). `limits.aiMonthlyCapCents` is the church's cap |
**Releases per product.** An install is told its own product's releases and latest version. A
release can need a minimum version of a sibling (`— requires accounts 1.2.0` in its WHATS-NEW.md
heading): v2 replies carry it as `requires: [{ product, version }]`, and an update request answers
`409 REQUIREMENT_NOT_MET` (with `requirements: [{ product, version, current }]` and a message saying
what's needed) until the church's install of that product runs that version or later.
**AI.** The monthly cap and markup are the church's, shared by all its installs: a call from any of
them counts what all of them used this month.
**Moving an install to v2** (e.g. Cross Events 2.4.0): register again with `protocolVersion: 2`,
the product and a public key (same licence and address: same install id, new secret), then send v2
heartbeats. Nothing on the Hub needs changing.