157 lines
12 KiB
Markdown
157 lines
12 KiB
Markdown
# Handover — Cross Code, all products
|
||
|
||
Last updated: 2026-11-21. **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 from 2.2.0; Accounts, Website and App to come), shared packages, 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.14.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.10.0 | **Released, deployed and tested** (Hub `v2.10.0`) |
|
||
| 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.3.1` on every server; the central server's agent is read-only) |
|
||
| 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** (now `accounts@1.6.0`; [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** (now `events@3.6.1`; [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 | **Released, deployed and tested** 2026-11-20 (below) |
|
||
| 5 | Church Website 1.0.0 | **Planned** 2026-11-21: [WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md) (all decisions confirmed). Not started |
|
||
| 6–7 | App 1.0.0 → App 1.x | Not started |
|
||
|
||
## 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 the 2026-11-20 releases is deployed, rolled out and tested
|
||
(VERSIONS.md, "Deployed / rolled out").
|
||
|
||
1. **Phase 5, Church Website 1.0.0** (ROADMAP §6, §9). Planned in
|
||
[WEBSITE-1.0-PLAN.md](./WEBSITE-1.0-PLAN.md): decisions all confirmed 2026-11-21. Order:
|
||
contracts 1.15.0 → Accounts 1.7.0 → Events 3.7.0 (shared fonts and footer) → Hub 2.11.0 →
|
||
`website@1.0.0` → Hope Family Church → a second church → crosscode-site 1.7.0.
|
||
2. **Archive `hope-events`** if it isn't yet (every install now reports 2.2.0 or later;
|
||
EVENTS-2.2-PLAN §7).
|
||
|
||
## 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`.
|
||
- **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.
|
||
- **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.
|