Feat v0.6.0 cluster registry (#36)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m40s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m22s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #36.
This commit is contained in:
2026-03-30 22:57:11 +00:00
committed by xcaliber
parent 768f15b3cd
commit 1a7f41493d
21 changed files with 1101 additions and 19 deletions

View File

@@ -2,6 +2,44 @@
All notable changes to Switchboard Core are documented here.
## v0.6.0 — Cluster Registry + HA
MVP convergence point. PG-backed cluster registry for horizontal scaling —
zero new infrastructure (no etcd/Consul/Redis).
### Added
- **Cluster registry**: `node_registry` UNLOGGED table with self-registration
on startup (`INSERT ... ON CONFLICT DO UPDATE`), heartbeat tick (default 10s),
stale sweep (default 30s threshold), and self-eviction (`os.Exit(1)` when
swept by a peer — K8s restarts the process).
- **Cluster admin API**: `GET /api/v1/admin/cluster` returns all registered
nodes with runtime stats (goroutines, heap, GC, uptime, ws_clients) in the
standard `{data: [...]}` envelope.
- **Health endpoint cluster info**: `GET /health` and `GET /api/v1/health`
now include `node_id` and `cluster: {size, peers, heartbeat_age_ms}` when
running on Postgres with the registry active.
- **Cluster dashboard**: `cluster-dashboard` admin surface package renders one
card per node with live runtime stats. Auto-refreshes every 10s. Stats are
JSONB — new keys render automatically without schema migration.
- **Cluster config**: `CLUSTER_NODE_ID` (default hostname-PID),
`CLUSTER_HEARTBEAT_INTERVAL` (default 10s), `CLUSTER_STALE_THRESHOLD`
(default 30s), `CLUSTER_ENDPOINT` (Phase 2 mesh, auto-detect).
- **3-replica E2E test**: `docker-compose-e2e.yml` now runs 3 replicas.
`ci/e2e-cluster-test.sh` verifies registration, stale sweep on stop, and
re-registration on restart.
- **5 new tests**: 3 cluster registry unit tests (stats collection, start/stop
lifecycle, node ID) + 2 handler tests (list nodes, empty response).
- **Curated bundle expanded**: `chat` and `cluster-dashboard` added to the
default bundle (now 10 packages). Production deployments can override with
`BUNDLED_PACKAGES=notes,chat,chat-core,cluster-dashboard` for a lean set.
### Changed
- SQLite deployments are unaffected — cluster store is nil, all cluster code
is guarded behind `database.IsPostgres() && stores.Cluster != nil`.
Cluster dashboard gracefully shows "0 nodes registered" on SQLite.
## v0.5.5 — Upgrade Testing
### Fixed