Skip to content

About

KyMessages Native: lightweight Go + PostgreSQL/SQLite multi-tenant chat and hybrid P2P/SFU conferencing server

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

KyMessages

Private team conversations, on infrastructure you control.

KyMessages is moving to Matrix for chat, with suite identity and sealed server backups. See the Matrix platform design. It is not deployed or approved for private team use yet. The source-built application currently provides the operator console and, once the Matrix stack below is configured, an "Open chat" link for members; without it they see a page saying chat is not available.

Build and inspect locally

Use the Go version in go.mod and a Node version supported by the pinned frontend packages. The committed web/dist is embedded in the binary. Rebuild it after UI changes:

make all
./kymessages version

To inspect the operator console with disposable data, choose a bootstrap password without putting it in shell history, then bind the server to loopback:

read -r -s -p 'Bootstrap operator password: ' KY_ADMIN_PASSWORD
export KY_ADMIN_PASSWORD
KY_HOST=127.0.0.1 ./kymessages

Open http://localhost:8080. Replace the bootstrap password before privileged use, then turn on two-factor sign-in under Settings > Account security. To create or reset the local administrator from a shell, run ./kymessages init-admin [-username <name>]; it reads the password from stdin (no echo on a terminal), never from the command line. The local administrator operates the service; member access requires suite OIDC. The default data directory is ./data; keep its encryption key with the database. make clean removes build artifacts, never runtime data or backups.

Container image

Compose runs the published image ghcr.io/busnes-app/kymessage-server:stable, the newest release. Each release vX.Y.Z is also published as :X.Y.Z with an SBOM and a build attestation, and only after CI passed on the tagged commit. docker compose pull moves to a newer release. To stay on one release, pin it by digest in KY_IMAGE after verifying its attestation; docker-compose.yml has the command.

Protect .env with mode 0600 and export KY_ADMIN_PASSWORD as above. The container never runs as root: create ./data and ./backups as yourself and set KY_UID and KY_GID in .env to your id -u and id -g (Compose refuses to start without them). It also drops every capability and runs with a read-only root filesystem; only ./data, ./backups and a /tmp tmpfs are writable. Then run docker compose up -d. The published port binds 127.0.0.1 by default. Container names, binary and local image are KyMessages-specific; the retained Go module path and token-sealing label are internal compatibility identifiers.

Upgrading from v0.4.2 or earlier: Compose now passes KY_SCIM_ENABLED, KY_BACKUP_KEEP and KY_BACKUP_DEPOSIT_INTERVAL from .env only when set (unset keeps the defaults: SCIM on, 7, 24h). A KY_SCIM_ENABLED in .env, ignored before, now applies. On a console set up by apply-setup, CLI deposit and export-capsule capsules from v0.4.2 or earlier lack its installer credentials: seal a new one (INSTALLER_SETUP.md).

Local container build

To run this checkout instead, build it with docker-compose.build.yml. Its image is kymessages:local, never pulled, and wins over KY_IMAGE. In a new .env, set:

COMPOSE_FILE=docker-compose.yml:docker-compose.build.yml

For an existing .env, append the build overlay to its current COMPOSE_FILE chain; keep any LAN-DNS/static-IP overlays. The build overlay contains an idempotent append snippet. Then run docker compose up --build.

Optional docker-compose.static-ip.yml requires KY_CONTAINER_IP and KY_NETWORK_SUBNET; otherwise Compose chooses addressing. Optional docker-compose.lan-dns.yml requires KY_DNS. Add either to the existing overlay chain. Do not replace that chain with an unrelated -f list.

Behind a reverse proxy, add docker-compose.proxy.yml (needs KY_APP_URL, KY_SESSION_SECRET and KY_TRUSTED_PROXIES; publishes no port; names the network kymessages-net). Setup, cloudflared and nginx are in docs/Reverse_Proxy_Networking.md.

Matrix chat

Chat is Matrix: Synapse, Matrix Authentication Service (MAS) and Element Web, with KyIdentity as the only sign-in. Voice and video calls are enabled by default through stock Element Call and LiveKit. HTTP services stay private behind the proxy; LiveKit publishes TCP 7881 and UDP 7882 for direct media (routes in docs/Reverse_Proxy_Networking.md). Registration is closed and MAS's compatibility (password) login is not served. Federation is closed by default; an operator can open it to named servers (see "Federation" below).

Encryption label: End-to-end encrypted in Element (not independently audited). In the acceptance run, every message Element sent to an encrypted room (direct and group) was stored encrypted and its text appeared nowhere in the database, but Synapse does not enforce encryption: a client or script that does not encrypt can post plaintext into an encrypted room, and the server does not stop it. Members should use Element. Even with encryption, the server sees room names and topics, membership, timestamps, display names and other metadata in plaintext. Evidence: docs/CHAT-PLATFORM-OPTIONS.md section 7.

Setup, with the proxy overlay already working. matrix-init runs twice: KyIdentity shows the client secret once, when you register the client the first run describes.

  1. Export these for matrix-init (it reads the process environment, not .env). Hosts are https origins without a path: KY_MATRIX_SERVER_NAME (for example example.com), KY_MATRIX_HOST, KY_MATRIX_AUTH_HOST, KY_MATRIX_CHAT_HOST, KY_ADMIN_HOST, KY_KYIDENTITY_ISSUER, KY_MATRIX_MAS_CLIENT_ID (a name you choose; not secret), KY_MATRIX_RTC_HOST (the HTTPS LiveKit signalling origin, for example https://sfu.example.com) and KY_MATRIX_MEDIA_IP (the IPv4 address clients can reach directly: public IP for remote callers, LAN IP for LAN-only use).

  2. Run ./kymessages matrix-init as the unprivileged user that will own the files (-dir defaults to ./matrix; it refuses root, and an existing directory that group or others can read). It writes every config except MAS's, prints the KyIdentity registration values and KY_MATRIX_UID/KY_MATRIX_GID. Without a source build, run it from the image the stack runs (swap in your KY_IMAGE pin if you set one), in the directory holding the Compose files; the image's entrypoint is /app/kymessages, and each -e NAME passes the value exported in step 1:

    docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/w" -w /w \
      -e KY_MATRIX_SERVER_NAME -e KY_MATRIX_HOST -e KY_MATRIX_AUTH_HOST -e KY_MATRIX_CHAT_HOST \
      -e KY_MATRIX_RTC_HOST -e KY_MATRIX_MEDIA_IP -e KY_ADMIN_HOST -e KY_KYIDENTITY_ISSUER \
      -e KY_MATRIX_MAS_CLIENT_ID ghcr.io/busnes-app/kymessage-server:stable matrix-init

    Use the same command wherever this guide says to run or re-run ./kymessages matrix-init. For TURN, mount the certificate and key too and pass KY_MATRIX_TURN_* as container paths. Back up matrix/secrets and matrix/synapse/signing.key; they are never regenerated. Upgrading a stack set up before matrix/federation/federation.yaml existed: re-run matrix-init first, or Compose refuses to start Synapse (it never creates that file), then docker compose up -d with your overlay chain. restart is not enough: it keeps Synapse's old command and the app's old mounts. The file is created closed; Settings owns it after.

  3. In KyIdentity, register the printed confidential client (client ID, redirect URI, back-channel logout URI, scopes openid profile email) and assign the users who may chat. Unassigned users cannot sign in. A user's Matrix ID comes from their KyIdentity email once KyIdentity has verified it (the user redeemed an activation or reset link it mailed; configure KyIdentity's mail delivery, as a link handed over by hand does not verify): its local part, lowercased, with characters outside [a-z0-9._=-] replaced by _ (Alice.Q+Ky@example.com becomes @alice.q_ky). A user without a verified email, or whose local part another chat user already has (alice@ on two domains), cannot sign in. The ID is fixed at first sign-in. The back-channel logout URI is what ends a disabled user's open Element sessions; without it they keep working until their token expires.

  4. Save the client secret KyIdentity shows to matrix/secrets/kyidentity_client_secret with mode 0600 (for example install -m 600 /dev/null matrix/secrets/kyidentity_client_secret, then paste it in with an editor). It lives only in that file, never in env or .env; matrix-init refuses it if group or others can read it.

  5. Run ./kymessages matrix-init again. It keeps every secret and now writes matrix/mas/config.yaml. Until then, docker compose up refuses MAS and the app with "bind source path does not exist". Whenever you re-run it on a running stack, apply the configs with docker compose restart synapse mas element livekit app (the app mounts each secret file, so it sees a replaced kyidentity_client_secret only after a restart). To rotate the Synapse or MAS database password, delete matrix/secrets/synapse_db_password or mas_db_password, re-run it and do what it prints: apply postgres/role-passwords.sql with psql on the running Postgres (its init script ran only on the empty volume), then restart synapse mas app.

  6. Pair a suite_webhook system in KyIdentity (callback https://<host>/api/sso/kyidentity/sync) and link it to the MAS client's app. KyIdentity shows its signing secret once: that is KY_KYIDENTITY_HMAC_SECRET. On a console set up by apply-setup it must equal the setup's directory secret file (INSTALLER_SETUP.md). Its directory events are what lock and deactivate users in MAS. If MAS and KyMessages resolve only to private addresses (LAN-only), set KYIDENTITY_ALLOW_PRIVATE_CALLBACKS=true on KyIdentity so it may call them.

  7. Add to .env: KY_MATRIX_UID and KY_MATRIX_GID as printed (the app then runs as that user too, so it must own ./data and ./backups; keep KY_UID/KY_GID equal), plus KY_MATRIX_SERVER_NAME, KY_MATRIX_HOST, KY_MATRIX_CHAT_HOST (KyMessages serves discovery and the chat link from them), KY_MATRIX_ADMIN_CLIENT_ID (printed by matrix-init) and KY_KYIDENTITY_HMAC_SECRET and KY_MATRIX_RTC_HOST. With Matrix enabled, KyMessages refuses to start with missing admin settings (client ID, readable non-empty secret file) or no webhook secret. A wrong admin secret still starts, but every offboarding sweep then fails; the failure is logged once per failure streak ([MATRIX] offboarding sweep failing), so check the logs after start (console health comes later). Postgres, Synapse and MAS run as that user, the owner of ./matrix, so its 0600 secrets stay unreadable to every other account; Compose refuses to start without these. If the UID or GID ever changes, chown -R ./matrix and the matrix-postgres and matrix-media volumes (prefixed with the Compose project name) to the new owner.

  8. Append docker-compose.matrix.yml to COMPOSE_FILE, after the proxy overlay, keeping the rest of the chain, then docker compose up -d.

  9. In KyIdentity, open the system's deliveries, resume any held one, resync the system (how: "After any KyMessages outage" below) and confirm every assigned user shows delivered before members rely on chat. The sweep locks a MAS user KyMessages has no record of; it unlocks when that user's delivery lands.

Upgrading from the Matrix setup before offboarding:

  1. Re-run ./kymessages matrix-init. It keeps every secret, adds the MAS admin client and its secret file, and prints KY_MATRIX_ADMIN_CLIENT_ID and the back-channel logout URI.
  2. Add that back-channel logout URI to the existing KyIdentity client.
  3. Pair and link the suite_webhook system (step 6) if you have not, and set KY_MATRIX_ADMIN_CLIENT_ID and KY_KYIDENTITY_HMAC_SECRET in .env.
  4. docker compose up -d, then docker compose restart synapse mas element so they read the new configs.
  5. Do step 9: confirm every assignee shows delivered before relying on chat.

After start:

  • Add the cloudflared routes, then open the chat host. Signed-in members see an "Open chat" link in KyMessages.
  • curl https://<server name>/.well-known/matrix/client must show your KY_MATRIX_HOST.

Offboarding, as measured by make matrix-acceptance (cut within 30 s, in practice 0.3-3 s):

  • Disable or unassign in KyIdentity: open Element sessions end and sign-in is refused; KyMessages locks the MAS user (sessions are gone either way, history stays).
  • Re-enable: MAS unlocks within seconds. Sign in again on a new device and restore keys from key backup with the security key to read earlier history; a device whose session ended stays ended.
  • Delete: MAS deactivates the user without erasing; they leave their rooms and colleagues still read their messages. A deactivated user is never reactivated.
  • Offboard in KyIdentity, not MAS. A lock applied by hand in MAS to someone active in KyIdentity is undone by the next sweep.
  • MAS's admin API listens on mas-admin:8081 on an internal network only KyMessages and MAS join; it is never routed.
  • After any KyMessages outage, open the system in KyIdentity and check its deliveries. A disable sent while KyMessages was down is held as an uncertain write ("operator recovery required") and is not retried: resume it (allowed after 60 s), then resync the system. In KyIdentity's Suite sync page: the system's Deliveries, tick the confirmation once the old request has finished, Resume delivery (KyIdentity asks you to confirm it's you), then the system's Resync Directory. Until then that user has no sessions and cannot sign in, but stays unlocked in MAS. Other failed deliveries KyIdentity retries itself.

Backups:

  • The scheduled server capsule includes Matrix: configs, secrets, signing key and pg_dumps of Synapse and MAS (one-time keys excluded). It leaves out the Postgres superuser password; restore recreates it with matrix-init.
  • What this costs: the app joins matrix-db and reads ./matrix to back it up. The configs there hold the synapse and mas database owner passwords and the MAS-Synapse shared secret, so a compromised app can write both databases and act as Synapse admin. It cannot decrypt end-to-end encrypted messages. Compose hides the superuser password from it.
  • Media is mirrored, encrypted, to KY_BACKUP_DIR/media after each scheduled run or kymessages deposit, with a full archive each month. Copy that directory off the host. deposit exits non-zero if the media step fails after a good deposit; backup-drill exits non-zero when any check fails.
  • The backup screen shows the capsule size, a warning from 75% of the 256 MiB limit and the last media run. "Run now" seals the capsule only.
  • Restore: see docs/RESTORE.md.

Upgrading a stack from before Matrix backups:

  1. Re-run ./kymessages matrix-init (adds kybackup_db_password and postgres/kybackup-role.sql).
  2. Run the role file once: docker compose exec -T postgres psql -U postgres -v ON_ERROR_STOP=1 -f /docker-entrypoint-initdb.d/kybackup-role.sql.
  3. docker compose pull app (or rebuild with the build overlay), keep KY_BACKUP_DIR set, and optionally set KY_BACKUP_MEDIA_FULL_KEEP.
  4. docker compose up -d. The first scheduled run then backs up Matrix.

Voice and video calls

Calling is enabled in Element by default for DMs and group rooms. Members start or join a call themselves; their browsers ask for microphone/camera permission. All callers must be active KyIdentity users who have joined that Matrix room. No Matrix identity server is needed.

Route KY_MATRIX_RTC_HOST over HTTPS/WebSocket to http://livekit:7880; never expose LiveKit's /twirp/ administration routes. The existing console route carries /api/matrix/rtc/get_token and /api/matrix/rtc/sfu/get, so Element can request grants with Matrix OpenID tokens. The app checks local identity, directory/MAS status and joined-room membership; it never trusts a caller-supplied server URL. See network setup.

Forward TCP 7881 and UDP 7882, unchanged, to the Docker host at KY_MATRIX_MEDIA_IP. KY_MATRIX_MEDIA_BIND_IP optionally limits which host interface Compose publishes on (default 0.0.0.0, every interface); for LAN-only use, set it to the host's LAN address. Cloudflared handles HTTPS/WebSocket signalling; its HTTP tunnel cannot carry these media ports.

For networks limited to TLS 443, export KY_MATRIX_TURN_HOST (DNS-only hostname resolving to that public media IP), KY_MATRIX_TURN_CERT_FILE and KY_MATRIX_TURN_KEY_FILE, and re-run matrix-init. Use a browser-trusted certificate covering that hostname; the input key must be 0600 or stricter. Append docker-compose.turn.yml to your existing overlay chain, then recreate LiveKit. Forward TCP443 to host 443 and UDP 3478 and 30000–30100 unchanged, alongside the direct ports. LiveKit listens internally on 5349 and advertises external 443. The generated private TLS copies enter encrypted backups. TURN permits only the configured media IP; deployment egress rules must also restrict ports when that IP serves other applications.

After ACME renewal, run matrix-init with the renewed certificate/key inputs, and restart LiveKit only after it succeeds. The whole private LiveKit directory is mounted read-only, so replacements become visible; LiveKit reads its certificate at startup. Renewal keeps API keys and invalid TLS input leaves generated files untouched.

Upgrade an existing stack by exporting the two new setup values, running matrix-init as its original owner, adding KY_MATRIX_RTC_HOST to .env, configuring the routes/media ports, and running docker compose up -d --force-recreate app synapse element livekit (preserve your Compose overlay chain). The new write-once LiveKit keys/config are included in backups. Update a moved host's media IP and re-run matrix-init before restarting LiveKit.

The call reconciler runs every 5 seconds and evicts users disabled/unassigned/deleted in the local directory, locked/deactivated in MAS, or removed from the Matrix room. LiveKit refreshes connected users' tokens: cached grants can reconnect between passes, and a stopped or failing control plane cannot evict media. Ending a MAS browser session alone does not end its active call. Calls are not recorded or restored. LiveKit routes media; the existing text encryption acceptance does not prove call encryption. make matrix-acceptance includes a separate real audio/video check; production networking still needs deployment verification.

Federation

Closed by default. Settings > Federation has three levels:

Level Who can reach this server
Closed nobody (as before; federation paths are 404)
Manual approval servers you add by name
Curated list + approval those, plus vetted public servers you tick (this release: matrix.org, mozilla.org, kde.org, gnome.org, fedora.im)

There is no open federation level. Both servers must list each other.

  1. One-time proxy change: route https://<server name>/.well-known/matrix/server to the app as well as the client file (cloudflared path ^/\.well-known/matrix/(client|server)$, docs/Reverse_Proxy_Networking.md). Federation then reaches Synapse through the existing KY_MATRIX_HOST route on port 443; 8448 stays shut.
  2. In Settings > Federation, choose a level. A wider level first lists what it exposes and needs a sign-in from the last 10 minutes; going back to Closed is one click.
  3. Copy "Your server" and send it to the other operator; type their server name and press Add server. They do the same with yours.
  4. Run the restart command the panel shows (docker compose restart synapse, or KY_MATRIX_SYNAPSE_RESTART_HINT): Synapse reads the list only at start. One restart covers several changes.
  5. "Check connections" shows each server as Connected, Not allowed yet (one side has not listed the other, or Synapse has not restarted), Their federation is off, or Unreachable.

What changes when a server is allowed:

  • Its servers see the metadata of rooms their users join (names, topics, membership, display names, timestamps). The chat label stays "End-to-end encrypted in Element (not independently audited)" with the caveat above (Synapse does not enforce encryption); encryption across servers is not covered by the acceptance run.
  • Offboarding someone here does not remove what was already sent to other servers. Closing a room removes this server from it; other servers keep it. Deleting a room deletes only this server's copy.
  • People on allowed servers can join calls in rooms they share with your users, through your LiveKit; only your users start calls. Removing a server or closing federation drops its callers within seconds, without waiting for the restart.
  • Public servers: what members post in a room on a public server reaches every server in that room, allowed or not; Synapse's allow-list cannot prevent that. Presets suit direct messages and small rooms. Servers marked "Open sign-up" let strangers invite your members.

The app writes Synapse's matrix/federation/federation.yaml from its settings; edit federation only in the console (hand edits are undone within a minute). Peers on private addresses (LAN only) are refused, by Synapse's default and by the app.

Agents

OpenClaw and Hermes Agent can chat here as their own Matrix account, @agent-<name>. None exist until you create one.

  1. Agents > Create agent: a name (agent- then a-z, 0-9, -) and the member who owns it. The owner must have signed in to chat once. The console lists what an agent exposes and needs a sign-in from the last 10 minutes.
  2. Copy the token and the config block for your runtime; the token is shown once. Download the skill and unzip it into ~/.openclaw/skills/ or ~/.hermes/skills/. The skill's references/ say where each block goes and how to verify the agent's device.
  3. The owner invites the agent to a room. Only the owner can start a turn.

Rotate replaces a token on the same device, so the agent keeps its encryption keys; the old token works for up to 2 more minutes (sign-in needed). Revoke cuts the token off at once, in one click, and deletes the agent's device: its next token comes on a new device, and the agent sets up encryption again. A token unused for 90 days is revoked the same way. Delete deactivates the account for good, keeping its messages. Offboarding the owner in KyIdentity locks the agent in about 2 minutes; re-enabling them brings it back.

An agent decrypts what it reads and sends it to its model; a hosted model takes room content off your infrastructure. Rooms keep Element's label regardless. Hermes keeps its token in plain text in ~/.hermes/.env.

Operator console

  • Overview shows chat health, Matrix users, backups and (with Matrix) a KyIdentity sync card (ok, warning or failing), each failing on its own.
  • Users lists Matrix users with their KyIdentity link. It ends one session or all of a person's sessions. There is no lock or unlock here: change access in KyIdentity.
  • Rooms lists every room (name, members, encryption, public or invite-only, creator, state events, open or closed) with search and paging, and a room's members. It never shows messages. Close is final: members are removed, rejoin is blocked, history stays. Delete permanently purges the room's history after you type its name (or its ID when it has none); the room's media (attachments, avatars) stays in the media store. Both run as background jobs, need a sign-in from the last 10 minutes and are audited as matrix.room_close and matrix.room_delete.
  • The console reaches Synapse's admin API as the service account @kymessages-console, which it creates in MAS on first use (a Rooms or Health load): no password, no KyIdentity link, not MAS admin. For each action it mints a 5-minute MAS session and revokes it afterwards. The offboarding sweep exempts exactly that unlinked account. A KyIdentity-linked account named kymessages-console is not exempt: the sweep judges it as a person and the console refuses it, so never give a KyIdentity user an email whose local part is kymessages-console. Locking the account in MAS cuts the console's room access.
  • Health probes Synapse, MAS, Element, Postgres, the database and this app on each load and compares each running version with the Compose pin. It links components to their upstream source and shows the network check. Each load also proves Synapse admin access as the console account: it reads one room.
  • Audit is the read-only log, filtered by kind (auth, backup, branding, matrix, scim).
  • Settings → Branding sets the product name (1–64 characters; blank returns to KY_APP_NAME) and the logo (PNG only, at most 1 MiB and 1024×1024 pixels, re-encoded so no embedded text or metadata survives). Both show on the next page load of the console and its sign-in page, and the logo in Element too. Element shows a new name after it restarts (docker compose restart element, or the command in KY_MATRIX_ELEMENT_RESTART_HINT): it serves a copy of its config made when it starts, and Settings shows that command while Element serves the old name. The app changes only the brand key of matrix/element/config.json, in place, through one of the two read-write files it mounts under ./matrix, and puts it back within a minute if matrix-init re-renders it. If it cannot write that file, the name is still saved and Settings shows what Element says and why. If a crash mid-write ever leaves that file truncated or invalid, Settings shows the error and a running Element is unaffected, but a restarted Element fails to load: re-run ./kymessages matrix-init; the app re-applies the name within a minute, then restart Element. Changes need a sign-in from the last 10 minutes and are audited (admin.brand_name, admin.brand_logo). KY_APP_NAME stays the backup service name: capsules and KyRecovery pairing never see the console name.
  • Settings → KyIdentity sync (with Matrix) shows the last directory webhook KyMessages accepted, deliveries refused since it started (and why: bad signature, stale clock, missing secret, bad headers, malformed body), and the last offboarding sweep, with what to fix. The Overview shows the same as a card. A change made while KyMessages was down waits in KyIdentity as an uncertain write; resume it there (Suite sync, the system's Deliveries).
  • Ending a session needs a sign-in from the last 10 minutes; the console asks "Confirm it's you" and retries after you sign in again. Each ending is audited as matrix.session_end.
  • Session IPs and devices are shown to admins only and are never logged or audited.

make matrix-acceptance proves encrypted storage in Element, a closed server, offboarding and its sync status, room close and delete, branding reaching Element, and backup then restore of a lost host (needs Docker, node and a KyIdentity checkout; see AGENTS.md).

Kubernetes (Ky cluster)

The K80/K81 deployment lives in busnes.app/ky-kubernetes (manifests, setup-kymessages.sh wizard and runbook; not versioned). Design record: docs/superpowers/specs/2026-10-02-k8s-deploy-design.md. It runs the same images and matrix-init output; there too the app runs as KY_MATRIX_UID, and Element is restarted with kubectl -n ky-stack rollout restart deployment/element (KY_MATRIX_ELEMENT_RESTART_HINT).

A cluster Synapse started with only homeserver.yaml keeps running, closed, and ignores Settings > Federation. To let the console open federation there, give Synapse the args run --config-path /config/homeserver.yaml --config-path /federation.yaml and a read-only subPath mount of federation/federation.yaml at /federation.yaml; give the app a writable subPath mount of the same file at /matrix/federation/federation.yaml; set KY_MATRIX_SYNAPSE_RESTART_HINT to kubectl -n ky-stack rollout restart deployment/synapse. Opening federation also needs Synapse egress to public addresses on 443 and 8448 and the apex /.well-known/matrix/server route; closed, neither is needed.

Identity and recovery configuration

Deployment is still unverified. Prepare these settings for the eventual HTTPS instance; the current operator-console preview is not a chat release (see docs/superpowers/specs/2026-10-01-matrix-platform-design.md):

Setting Purpose
KY_APP_NAME Defaults to KyMessages; also the capsule service name, pinned at pairing
KY_APP_URL Exact public origin used for OIDC, browser Origin checks
KY_ADMIN_USERNAME Username of the local admin created on an empty database and init-admin's default, default admin; 3-64 letters, digits, ., _ or -. Set it before first start when a KyIdentity user is called admin (KyIdentity's own admin cannot be renamed): a KyIdentity user whose username a local account holds is refused, never merged into it. It has no effect on an existing database. After resolving a clash (renaming the local account or the KyIdentity user), press Resync Directory on the KyMessages system in KyIdentity; KyIdentity does not resend a refused new user on its own
KY_TENANCY_MODE=multi Shared multi-org install on several replicas. Requires KY_DB_DRIVER=postgres, a canonical KY_STAFF_ORG_ID, and secrets every replica shares: KY_SESSION_SECRET, KY_ENCRYPTION_KEY (or a shared data/encryption.key), and KY_VAPID_PRIVATE_KEY (or a shared data/vapid.key) unless KY_PUSH_ENABLED=false. None is minted at start. KY_ATTACHMENTS_DIR must be one volume every replica mounts: each blob is stored under orgs/<org_id>/att/, and a replica whose directory holds a different .store-id than the database records refuses to start. Each org's attachments count against its KyIdentity storage pool; KY_ATTACHMENTS_MAX_TOTAL_BYTES is ignored (startup warns), while KY_MAX_UPLOAD_BYTES and KY_ATTACHMENTS_MAX_PENDING_USER_BYTES stay as safety limits. Background jobs run on one replica at a time (PostgreSQL leases), migrations take an advisory lock, and the capsule backup scheduler is off: see docs/RESTORE.md
KY_ENV=production Requires a durable KY_SESSION_SECRET and an https KY_APP_URL (unless KY_COOKIE_SECURE=false)
KY_COOKIE_SECURE Defaults to true for production or any https KY_APP_URL; also turns on HSTS for the KY_APP_URL host. With it on and KY_COOKIE_DOMAIN unset, auth cookies carry the __Host- prefix
KY_SSO_ENABLED Default true; false turns KyIdentity sign-in off (its routes answer 404)
KY_KYIDENTITY_ISSUER, KY_KYIDENTITY_CLIENT_ID, KY_KYIDENTITY_SECRET Suite KyIdentity OIDC client; register https://<host>/api/sso/kyidentity/callback as its redirect URI and https://<host>/api/sso/kyidentity/logout as its back-channel logout URI. The former KY_KYSIGNON_* names stop startup
KY_MATRIX_RTC_HOST, KY_MATRIX_MEDIA_IP LiveKit HTTPS signalling origin and directly reachable media IPv4; required by matrix-init; set the host in .env too
KY_MATRIX_TURN_HOST, KY_MATRIX_TURN_CERT_FILE, KY_MATRIX_TURN_KEY_FILE Optional complete TURN/TLS setup block for matrix-init; DNS-only hostname and trusted PEM files; enable the TURN overlay
KY_MATRIX_MEDIA_BIND_IP Host interface for direct TCP 7881/UDP 7882, default 0.0.0.0; does not change the advertised media IP
KY_KYIDENTITY_HMAC_SECRET Signing secret KyIdentity shows once when you pair a suite_webhook system; set that system's callback URL to https://<host>/api/sso/kyidentity/sync; required with the Matrix stack
KY_TRUSTED_PROXIES Only the reverse proxy's own addresses/CIDRs, not the whole container network
KY_SCIM_TOKEN Stable provisioning credential when SCIM is used; no automatic SCIM-to-room mapping
KY_BACKUP_DIR, KY_BACKUP_KEEP Optional local sealed copies; keep newest N (default 7)
KY_BACKUP_MEDIA_FULL_KEEP Monthly full media archives kept, default 3; below 1 fails startup
KY_BACKUP_DEPOSIT_INTERVAL Initial schedule, default 24h; 0 disables, otherwise at least 15m; admin UI overrides without restart
KY_BACKUP_ALLOW_PRIVATE_RECOVERY Explicit LAN KyRecovery opt-in, off by default; HTTPS remains mandatory and loopback is refused
KY_MATRIX_ELEMENT_RESTART_HINT Command Settings shows for restarting Element, default docker compose restart element; one line, at most 256 bytes

Pin the suite public key manually or pair with KyRecovery, and compare its fingerprint with the ceremony record. A pinned key needs at least one destination: local directory or KyRecovery. One backup run seals once for both destinations and checks the remote receipt digest. The backup screen shows destinations, schedule and the latest recorded attempt, including scheduled/local-only failures and partial-success warnings. The last successful remote receipt stays separate. Unpairing keeps the key pin and local copies; separately revoke the product token at KyRecovery. Never put custodian shares into the running server.

Only SQLite has a supported capsule backup/restore path. The backup is one server capsule (accounts and settings, plus the Matrix stack when enabled). Restore invalidates stale grants. See the restore runbook before relying on backups. If a prior test pairing used the scaffold's Busnes.app service name, preserve that explicit KY_APP_NAME for its existing token/capsules; changing the default does not change KyRecovery's pin.

Verification

make ci runs formatting, module checks, race tests, frontend tests and the running server smoke checks. make test-postgres needs a disposable PostgreSQL 18 instance. See web/AGENTS.md for production-CSP, keyboard and responsive browser checks. The smoke CI job also runs python3 scripts/backup-acceptance.py, a three-minute disposable test of actual scheduler ticks, local-copy failures and live schedule changes. CI builds/runs the container, checks dependencies and verifies committed frontend assets; it publishes nothing. Publishing a GitHub release vX.Y.Z runs .github/workflows/release-image.yml: it refuses a tag that disagrees with any version source (internal/config/config.go, web/package.json, web/package-lock.json) or a commit on which any CI job did not pass, then publishes :X.Y.Z, attests and verifies it, and moves :stable unless the release is a prerelease or older than the newest one.

Container-local installer integration

KyQuickStart configures the console through kymessages apply-setup; protected inputs, inspection, graceful activation and Matrix/recovery gates are in INSTALLER_SETUP.md.

About

KyMessages Native: lightweight Go + PostgreSQL/SQLite multi-tenant chat and hybrid P2P/SFU conferencing server

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages