Files
crosscode-platform/docs/HANDOVER.md
T
joshuaandClaude Opus 5.5 d3789f9b30 docs: Hub 2.26.0 released; devotionals endpoint in hub-protocol.md
Hub 2.26.0 (the App from New install, demo scenarios, devotionals) in
VERSIONS.md, the handover and APP-1.0-PLAN, not deployed yet; §3c in
hub-protocol.md for GET /api/v2/devotionals (same as events-hub's copy).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 22:25:15 +02:00

243 lines
23 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Handover — Cross Code, all products
Last updated: 2026-11-30. **The plan is [ROADMAP-v3.md](./ROADMAP-v3.md)** (decided 2026-11-03,
decisions table near the end). This file says where each phase stands and what comes next.
Product-specific notes (where the code lives, known gaps) stay with each product: Cross Events'
are in [`apps/events/docs/HANDOVER.md`](../apps/events/docs/HANDOVER.md), and the Hub's are in
`events-hub/docs/` and `events-hub/deployment.md`.
The docs for every product are here in `docs/`: the roadmap, the Hub protocol
([hub-protocol.md](./hub-protocol.md), with a copy in `events-hub`), this handover, the plans
for each phase and the rollout checklist ([ROLLOUT-1.0.md](./ROLLOUT-1.0.md)). The latest
version of everything, and what's deployed, is in [VERSIONS.md](./VERSIONS.md) (update it with
every release).
## Repos
| Repo | What |
|------|------|
| `joshua/crosscode-platform` (this one) | Contracts, the apps (Events, Accounts, the Website; the App in phase 6), shared packages (`contracts`, `auth-client`, `seo`, `ui`, `demo`), the `crosscode` script (`scripts/`), the server agent (`apps/agent`), and these docs |
| `joshua/hope-events` | Cross Events up to 2.1.x. Frozen; archived once every install is adopted (EVENTS-2.2-PLAN §7) |
| `joshua/events-hub` | Cross Code Hub. Its own server, its own `scripts/deploy.sh` |
| `joshua/crosscode-site` | crosscode.co.za. Updated at the end of every phase that changes what it says (ROADMAP §9) |
## Where each phase stands (ROADMAP §9)
| Phase | What | State |
|-------|------|-------|
| 0 | contracts 1.0.0 → 1.21.0 | **Released and in use.** Not published to a registry (decision 22): the Hub gets a packed release committed to its repo (`backend/vendor/`) |
| 1 | Hub 2.0 → 2.20.0 | **Released, deployed and tested** (Hub `v2.20.0`; now `v2.26.0`, VERSIONS.md) |
| 1b | Cross Events 2.2.0: moved here as `apps/events`, the `crosscode` script | **Released, rolled out and tested.** Every install adopted onto the monorepo |
| 1c | Cross Events 2.3.x: authenticator app 2FA | **Released and rolled out** (carried into Accounts in phase 4) |
| 1d | Agent 1.x + Hub 2.1+ | **Released, rolled out and tested** (agent `1.5.0` on every server: from 1.4.0 the Hub reads and changes frps's / frpc's config and probes ports before an install; from 1.5.0 one product of a church can be uninstalled, exported or purged) |
| 2 | Cross Events 2.4.0: protocol v2, Linked products, event feed, `packages/seo` | **Released, rolled out and tested** ([EVENTS-2.4-PLAN.md](./EVENTS-2.4-PLAN.md)) |
| 3 | Accounts 1.0.0 | **Released, rolled out and tested** (`accounts@1.8.0` rolled out; `1.9.0` released 2026-11-30 for phase 6, not deployed; [ACCOUNTS-1.0-PLAN.md](./ACCOUNTS-1.0-PLAN.md)) |
| 4 | Cross Events 3.0.0: sign-in through Accounts | **Released, rolled out and tested** (`events@3.7.2` rolled out; `3.8.0` released 2026-11-30 for phase 6, not deployed; [EVENTS-3.0-PLAN.md](./EVENTS-3.0-PLAN.md)). Churches sign in through their Accounts; crosscode-site `v1.6.0` deployed |
| 4+ | Running it: jobs from the dashboard, styled emails, .env from the Hub, sign-in health, the nightly people check; then frp config and one-product uninstalls, and the Hub's popups, pickers and port list | **Released, deployed and tested** 2026-11-20 and 2026-11-23 (below) |
| 5 | Church Website 1.0.0 | **Released 2026-11-26** (planned 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md), all decisions confirmed). Font pairings confirmed 2026-11-24, section variants per template 2026-11-25 (§3). `contracts@1.17.0`, `accounts@1.7.0` and `events@3.7.0` released 2026-11-24, Hub `v2.21.0` 2026-11-25 (the Hub deployed 2026-11-25; the others not rolled out yet). `contracts@1.18.0` and Hub `v2.22.0` (Get more storage) released 2026-11-25, the Hub deployed 2026-11-26. **`website@1.0.0` and `1.0.1` released 2026-11-26**, crosscode-site `v1.7.0` (the Website on sale) released 2026-11-26. **Done** (confirmed by Joshua 2026-11-30): crosscode-site deployed, Hope Family Church and a second church live, the remaining release checks finished. Now `website@1.8.0` (VERSIONS.md) |
| 6 | Church App 1.0.0 | **Under way** (planned and started 2026-11-30): [APP-1.0-PLAN.md](./APP-1.0-PLAN.md), decisions confirmed 2026-11-30 (decision 13, the demo scenarios, added the same day); mockup on the Design canvas "Church App 1.0 mockup". Released 2026-11-30, not deployed: `contracts@1.20.0` to `1.23.0`, `accounts@1.9.0`, `events@3.8.0`, `website@1.8.0`, `agent@1.7.0`, Hub `v2.26.0` (below). Next: deploy the Hub, the first devotionals, `app@1.0.0` |
| 7 | App 1.x | Not started |
## Released 2026-11-30 (phase 6, first steps)
Tagged and pushed on 2026-11-30, **not deployed yet** (Accounts and Events have one migration each; the Website and the agent none). Details in
[VERSIONS.md](./VERSIONS.md), [CHANGELOG.md](../CHANGELOG.md) and the apps' CHANGELOGs.
| Release | What |
|---------|------|
| `contracts@1.20.0` | The App's contracts: `crosscode.devotional/1` and the devotionals CSV checks (shared by the Hub and the App), the Bible books and seven translations with YouVersion ids, `messaging.get` / `messaging.changed`, `whatsapp.optout` and `whatsapp_opted_out`, `APP_MODULES`, the `app` part of the church export |
| `contracts@1.21.0` | `agent.DEMO_SCENARIOS`: the eight demo churches, one per Website demo profile; `scenario` in `seed-demo`, `accounts` in `DEMO_PRODUCTS` |
| `accounts@1.9.0`, `@crosscode/demo` 1.0.0 | `messaging.get` for the App; the WhatsApp opt-out for every product (STOP kept per number and account, Accounts' own WAWP webhook, "Turn WhatsApp back on"); a scenario's church profile, SVG logo and icon, and people (`crosscode demo <church> accounts --profile <scenario>`) |
| `contracts@1.22.0` | Only free Bible translations in 1.0 (KJV and the new BSB: `licence`, `FREE_BIBLE_TRANSLATION_IDS`, the CSV `translations` option); the publishers' exact notices (NLT, ESV and the Afrikaans ones were out of date), the Bible Society's disclaimer, an `acknowledgement` per translation, who to ask, `FREE_QUOTE_VERSES` and `quotedVerses` ([BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)) |
| `events@3.8.0`, `@crosscode/demo` 1.1.0 | STOP stops all WhatsApp (not only news), checked before every message and passed on to Accounts; the eight scenarios as Events demo profiles, around each church's own people and campuses |
| `contracts@1.23.0`, `agent@1.7.0` | `seed-scenario`: a whole demo scenario in one job, on whatever the church has installed (Accounts first, the rest skipped, every release checked first); `seed-demo` for Accounts and the App, and `--scenario` passed on to every product |
| `website@1.8.0` | A profile loaded with `--scenario` takes the scenario's people as its leaders and, with a linked Cross Events, shows Events' events through the feed instead of its own; `crosscode demo <church> website --scenario`; `packages/demo` built with the Website. No migration |
| Hub `v2.26.0` | The App from New install (Accounts 1.9.0 first) and in every product list and filter; **Load a demo scenario** on a demo client (one `seed-scenario` job, "out of step" installs); demo data for every product; the Website's and App's .env; **Devotionals** (3 months ahead, Import CSV, KJV/BSB only) and `GET /api/v2/devotionals` (hub-protocol.md §3c); the App's tier alert. One migration (Hub) |
All four were checked on PostgreSQL 18 (local, details in `temp/`, never committed): migrations,
scenario loads, the opt-out.
## Released 2026-11-23
All tagged, pushed and deployed on 2026-11-23. Details in [VERSIONS.md](./VERSIONS.md) and the Hub's
CHANGELOG.
| Release | What |
|---------|------|
| `agent@1.4.0`, `contracts@1.15.0`, Hub `v2.11.0` | The agent finds frps's / frpc's config wherever it is (TOML too); each server's Hub page reads and changes it (secrets stay on the server, verify, backup, put back if frp doesn't start, two-factor). New installs probe their ports on the central and church server first (`probe-ports`) |
| `agent@1.5.0`, `contracts@1.16.0`, Hub `v2.12.0`, `crosscode` script | Uninstall, export and purge **one product** of a church (`crosscode uninstall|export|purge <church> [product …]`); the last one removes the church; Accounts goes last. Stale installs removable from the Hub; customers archivable; several emails per customer |
| Hub `v2.13.0` | Alerts cleared by hand; billing tables sortable |
| Hub `v2.14.0` – `v2.17.0` | Customer and install pages as a header, tiles and tabs; every add and edit in a popup (frontend only) |
| Hub `v2.18.0`, `v2.19.0` | Releases picked from a list; the server agent's own releases on the Releases page and in Update agent (migration `AgentRelease`) |
| Hub `v2.20.0` | The port list says what each port is for; frps's allow_ports checked against it |
| crosscode.co.za `v1.6.1` | Clearer web address choices on the Cross Events page |
## Released 2026-11-20
All tagged, pushed, deployed and tested (confirmed by Joshua 2026-11-21). Details in [CHANGELOG.md](../CHANGELOG.md), the apps' CHANGELOGs
and What's New, and [VERSIONS.md](./VERSIONS.md).
| Release | What |
|---------|------|
| `events@3.4.0`, `accounts@1.4.0`, `contracts@1.12.0`, `agent@1.3.0`, Hub `v2.8.0` | Background jobs switched on/off and rescheduled from each site's admin (saved in `job_overrides`, wins over the .env, applies at once; Accounts gets an Admin → Background jobs page). Accounts' emails styled as Events' (`src/lib/emails.ts`). The Hub reads and changes an install's .env (`env-read` / `env-set` jobs → `crosscode env`; secrets never leave the server; the file is put back if the site doesn't start; the frontend's file triggers a rebuild) |
| `events@3.5.0`, `contracts@1.13.0`, `agent@1.3.1`, Hub `v2.9.0` | **Fix:** "Load demo data" deleted the Accounts link (`set-demo.js` truncated `ProductLink`), so events-demo couldn't sign anyone in (`ACCOUNTS_UNAVAILABLE`). Demo data keeps the link; a site in Accounts mode without a link reconnects at its next heartbeat. Heartbeat `stats.signIn`; Hub alerts: not linked (critical), wrong Accounts, sign-in failing, an Accounts nothing links to. **Agent 1.3.0 reported itself as 1.2.0**: use 1.3.1 |
| `accounts@1.6.0` | A "New sign-in" email (and WhatsApp) after every sign-in; Sign-in settings → `signin_notices` turns it off |
| Hub `v2.10.0` | Every Hub email laid out as Events' and Accounts' (`src/utils/emailLayout.js`: header with the logo, button, notes, job steps, code blocks; plain text kept). The FastPanel email gives `location ^~ /api/` as config to paste; Proxy done checks a file under `/api` reaches the backend. Billing emails unchanged |
| `events@3.6.1` | **Fix:** logo/favicon uploads failed on events-demo ("uploaded, but the site can't show it yet"). FastPanel's static-file rule sent every `/api/…` path with a file extension (`.png`, `.pdf`, …) to the frontend. The site now passes `/api/*` and `/uploads/*` on to the backend (`BACKEND_INTERNAL_URL`); the installers' nginx uses `location ^~`. Change each FastPanel site too (below) |
| `events@3.6.0`, `accounts@1.5.0`, `contracts@1.14.0` | The nightly people check (`accounts-people-check`, 04:30): `people.check` 500 subs at a time; fixes out-of-date copies, handles deleted accounts as `user.deleted`, stops (changing nothing) when most people are unknown. Skipped with an Accounts before 1.5.0 |
## FastPanel sites (central server)
FastPanel's nginx on the central server is the only router for sites behind frp: the church
server has no nginx. Its static-file handling adds a regex location for file extensions
(`png|jpg|ico|svg|css|js|pdf|txt|…`) that falls back to the site's main proxy, the frontend. A
plain `location /api` loses to it, so `/api/uploads/…/logo.png` reached Next.js and got a 404
(fixed in the site by Events 3.6.1, but slower and without the visitor's IP). In each Events
site's nginx config in FastPanel, the backend locations must be `^~` (a prefix match that no
regex can override):
```nginx
location ^~ /api/ {
proxy_pass http://127.0.0.1:<api port>;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location = /api { proxy_pass http://127.0.0.1:<api port>; }
```
Since **Hub 2.10.0** the FastPanel email (AGENT-1.0-PLAN §11) gives this block to paste, and
**Proxy done** refuses a site whose `/api/proxy-check.png` reaches the frontend. Sites set up
before that need the change by hand, and so does the Hub's own site (`events-hub`,
`/api/…/statement.pdf`; its deployment.md §8). Check after a change:
`curl -sI https://<domain>/api/health.png` must not say `X-Powered-By: Next.js` (a 404 is fine).
## Next up
Everything up to and including phase 5 (the Church Website) is released and rolled out: Hope
Family Church and a second church are live on the Website, crosscode-site sells it (confirmed by
Joshua 2026-11-30; VERSIONS.md, "Deployed / rolled out").
1. **Phase 6, Church App 1.0.0** (ROADMAP §7, §9), [APP-1.0-PLAN.md](./APP-1.0-PLAN.md) §15.
**Done 2026-11-30 (released, not deployed):** contracts 1.20.0 to 1.23.0, Accounts
1.9.0, Events 3.8.0, Website 1.8.0, agent 1.7.0. The Bible publishers' terms checked: none covers a sold app, so **1.0 uses only the
free translations, the KJV and the Berean Standard Bible** (APP-1.0-PLAN decision 14); the
permission requests for the others are drafted in [BIBLE-PERMISSIONS.md](./BIBLE-PERMISSIONS.md)
for later, and nothing waits for them. **Next:**
1. ~~**Website 1.8.0**~~: **released 2026-11-30** (not deployed). A profile loaded with
`--scenario` takes the scenario's people as leaders (`scenarioTeam` in `src/demo/seeds.ts`)
and, with a linked Cross Events, shows Events' events through the feed; `crosscode demo
<church> website --scenario`; the Website builds `packages/demo`.
2. ~~**Agent 1.7.0**~~ and **contracts 1.23.0**: **released 2026-11-30** (not rolled out).
`seed-demo` for `app` and `accounts`, `--scenario` passed on; the new `seed-scenario` job
(`crosscode demo <church> --scenario <s>`) loads the scenario on every product the church
has installed, skipping the rest, every release checked first; `crosscode demo <church> app` refused clearly until
App 1.0.0 brings `scripts/products/app.sh` and the App's demo.
3. ~~**Hub 2.26.0**~~: **released 2026-11-30** (not deployed). Was: the App in New install and releases, billing on
the active-member band, **Load a demo scenario** on a demo client (one `seed-scenario` job,
agent 1.7.0+: the server seeds whatever the client has installed, Accounts first; show the
report's `loaded` / `skipped`), the **Devotionals** page
(3 months ahead, Import CSV, the free translations only: KJV and BSB) and
`GET /api/v2/devotionals`. **Next:** deploy it (`scripts/deploy.sh` in events-hub, one
migration), then write or import the first 3 months of Cross Code devotionals in the KJV or
BSB (Hub → Devotionals).
4. **`app@1.0.0`** → cross-demo2 (every scenario loaded, the throwaway install from the Hub) →
Hope Family Church → crosscode-site 1.10.0 (the App on sale).
Deploying Accounts 1.9.0, Events 3.8.0 and Website 1.8.0 to the churches can happen any time before the App;
a church without Cross Events gives WAWP the address in Accounts → Admin → Email and WhatsApp.
Done (confirmed by Joshua 2026-11-25): `hope-events` is archived, and every FastPanel site set up
before Hub 2.10.0, and the Hub's own site, has `location ^~ /api/`.
## The VM test (2026-11-17)
Everything above was run on a WSL Ubuntu 24.04 VM before release: a church server, a "central"
network namespace running frps with `proxy_bind_addr`, the Hub (`feat/servers-agent`) and local
git mirrors standing in for c-git. It found nine bugs, all fixed with tests before tagging. None
lost data, because each failed safely:
1. `adopt` refused a release with new migrations (it now applies them in the switch-over).
2. A failed migration blocked every later deploy (Prisma P3009; now marked rolled back).
3. The agent install skipped the root's build tools (`npm ci --include-workspace-root`).
4. A failed install's short name couldn't be used again.
5. The Hub didn't save the servers settings (install defaults, port range, central IP).
6. frpc only reads its admin lines when it starts (restarted once the first time).
7. **A site's PM2 belonged to the agent's service**, so stopping or updating the agent took down
every site it had installed. PM2 now always runs under `pm2-<user>`.
8. Update and closing banners never reached Hub-installed sites (registration now links them).
9. A moved tag blocked a church's deploys (tags are fetched with `--force`).
Not covered by the VM: FASTPANEL, real DNS, Let's Encrypt. Hence the throwaway install in the
rollout.
## Things to remember across phases
- **Before selling the Website or App:** put the ROADMAP §10 prices in
`crosscode-site/src/data/pricing.mjs` *and* the Hub's `frontend/src/lib/tiers.ts` (plus
`backend/src/utils/billing/tiers.js`) in the same phase, so the site and the Hub never disagree.
- **A phase isn't done until crosscode-site matches it** (ROADMAP §9, "Updating crosscode-site").
- Servers stay **PM2 + nginx** (no Docker), with one database per product per church, under
`/var/www/sites/<church>/<product>`. Each site user's PM2 runs as a systemd unit,
`pm2-<user>`; the `crosscode` script makes sure of it before any PM2 command.
- **The agent pins the Hub's job key** when it joins. Back up `events-hub/backend/keys/` (licence
and job keys); replacing the job key means every server joins again.
- **A new `.env` variable** goes in three env templates: `apps/<product>/env.template.json`,
`scripts/products/<product>.env.template.json` and the Hub's `envTemplates/<product>.json`. If
the app refuses some values at startup (as Events does a `TRUST_PROXY` it can't parse), add a
rule to both `checkEnvValue` in `packages/contracts/src/agent.ts` (the Hub) and `VALUE_RULES` in
`scripts/lib/envtpl.cjs` (the server), so a bad value stops before an install's build.
- **Demo data:** Hub → the install's page → Mark as a demo site → Load demo data (Hub 2.4.0, agent
1.2.0; `crosscode demo <church> --profile …` on the server). By hand, run `npm run demo:*` as the
site's user (`sudo -u cc-<church> …`): only that user can read the `.env`.
- **Demo scenarios** (APP-1.0-PLAN §12, from 2026-11-30): eight preset churches, the list in
contracts `agent.DEMO_SCENARIOS`, each church's profile, people and logo in `packages/demo`
(`@crosscode/demo`, built by every product that uses it). **Accounts loads first**
(`crosscode demo <church> accounts --profile <scenario>`: profile, logo, people), then Events,
the Website and the App with the same profile name. People keep the same account id everywhere
and on every load (`demoId`); everything is at example.com with no phone numbers. A new demo
feature that should look the same in every product goes in `packages/demo`, not in one app.
**A whole scenario is one job** (contracts 1.23.0 `seed-scenario`, agent 1.7.0):
`crosscode demo <church> --scenario <s>` loads it on **whatever the church has installed**,
Accounts first, and skips the rest (a client with only Accounts and the Website gets both).
Every product must also work without the others (the Website without Accounts uses the
scenario's own profile, without Events its own events); the App 1.0.0 must do the same, and
add its branch to `cmd_demo_scenario` in `scripts/lib/manage.sh`.
- **WhatsApp STOP** (APP-1.0-PLAN decision 11, from Accounts 1.9.0 / Events 3.8.0): STOP means no
WhatsApp from any product, of any kind. Accounts keeps it (`whatsapp_opted_out` in
`user.updated`); every product checks it before sending (Events: `utils/whatsappStop.js`), and
whichever product receives a STOP passes it on with `whatsapp.optout`. The App and the Website
must do the same.
- **Bible text** (BIBLE-PERMISSIONS.md, from contracts 1.22.0): the Hub and the App offer only
`FREE_BIBLE_TRANSLATION_IDS` (KJV, BSB). Any other needs its publisher's written permission
first, then brings its exact `copyright` line (and the Bible Society's `disclaimer` for
AFR53/AFR83), copied from the publisher, never reworded. **No AI on Bible text**, ever: Crossway and Biblica forbid it.
- **A new Events install never takes over an existing database**: moving an existing site is
`adopt`, not a New install pointed at the old database.
- **Prisma in the monorepo:** each app other than Events sets its own generator `output`, so
hoisted clients don't overwrite each other (EVENTS-2.2-PLAN §2).
- **AI for a church:** set the licence's monthly AI cap above R0 on the Hub; with no cap the
buttons don't show (rules in Events' handover, "AI rules"). Churches see tokens; only the Hub
shows rand (markup 15% by default).
- **The agent's version is in two places:** `apps/agent/package.json` *and* `AGENT_VERSION` in
`apps/agent/src/stats.ts` (what it reports to the Hub). Bump both; the agent's test checks they match,
so run `npm run check` *after* the bump (1.3.0 shipped reporting 1.2.0).
- **Background jobs:** each job's switch and schedule can be set in the site's admin (Events and
Accounts, AppSetting `job_overrides`); that wins over the .env flag and `JOB_SCHEDULE_<NAME>`.
`JOBS_ENABLED=false` still turns everything off. A new job gets a `label` and, if it may be turned
off from the .env, an `env` flag.
- **An install's .env from the Hub** (install page → Settings (.env), agent 1.3.0+): plain values
only. Names matching `SECRET_ENV_NAME` (contracts) / `SECRET_NAME` (`scripts/lib/envedit.cjs`;
keep them in step) and generated values can't be read or changed from the Hub. Changing an
address there doesn't change the Hub's domain for the install or FastPanel.
- **Demo data keeps the links** to the church's other products (`KEEP_TABLES` in
`apps/events/backend/scripts/set-demo.js`). Anything that must survive a demo load goes there.
- **A local PostgreSQL** is on the dev machine (`temp/database details.txt`, git-ignored; the user is
`postgres`, the file says `postges`). Use a throwaway database per check (`cc_<app>_<version>_check`),
run `prisma migrate deploy` and `prisma migrate diff --from-config-datasource --to-schema …`, and drop
it afterwards. Never print the password. Events' database has an older drift on
`_EventNotifyRecipients` (an index Prisma now wants as a primary key), not from 3.8.0.
- **Releasing:** branch → merge → tag (`<product>@<version>` here, `v<version>` in events-hub and
crosscode-site) → push, with a CHANGELOG entry, and `npm run check` first. Pushes to c-git often
fail authentication the first time; retry once. A push can also hang waiting on a login prompt
after it has already gone through: check with `git ls-remote` before pushing again.