Records Feature record

FDR-018

Account Lifecycle

Active Last reviewed 2026-10-27 Source file

Overview

This FDR covers human accounts from registration through deletion: signup, email verification, self-service account deletion, and the crypto-shredding model that makes deletion permanent and reliable. The same deletion and crypto-shredding mechanics also apply when a bot is deleted through its management API, as specified by FDR-038. Authentication mechanics (login, sessions, tokens) live in FDR-023.

Behavior

Registration

  • On invite-only servers, a human user first supplies a single-use invitation code (FDR-036). The code is consumed only when account creation succeeds.
  • Direct registration starts with an email address. Chatto returns the same generic response whether the address is available or already claimed, so the registration endpoint does not disclose existing accounts.
  • Chatto sends a six-digit verification code to an available address. Verifying the code returns a short-lived completion token; it does not create an account.
  • The user then chooses a login and password. The login must pass uniqueness, format, and blocked-username checks, and the email is checked again in case it was claimed while the completion token was outstanding.
  • Successful completion creates the account with the email already verified. There is no partially registered or unverified account state in the direct-registration flow.
  • Registration and verification codes are backed by RUNTIME_STATE HMAC-derived records with configurable per-key TTLs (default 30 minutes). Raw code values are never written to EVT or backup archives. If email delivery fails, the pending OTP is cancelled so the failed send does not consume resend throttle capacity.
  • If the verified email matches an entry in owners.emails in the server config, the new user is auto-assigned the owner role when the verified email is attached.

Email management

  • A human user can have multiple verified email addresses on file. Bot accounts cannot have verified emails.
  • Before Chatto sends a code, Account Settings asks the user to enter the new address twice. The dialog says that Chatto will send a six-digit verification code to this address.
  • Adding a new email sends a verification code to the new address and opens a separate confirmation page. The page uses the same six-digit control as direct registration. It keeps the pending address in server-scoped session storage so a page reload does not lose the pending verification. Chatto adds the email only after the user confirms the code.
  • If another tab signs in to a different account, an already-open tab refuses to load or change email settings until its account state is refreshed. It does not show or change the other account's email addresses.
  • A successful confirmation removes its tab-scoped pending challenge even when the user navigates away before the response arrives. The consumed code does not appear again when the user returns to the confirmation page.
  • An address that is already verified cannot start another verification ceremony.
  • The first verified email becomes the primary email. Adding another email does not change the primary email. The user can select any verified email as the primary email in Account Settings.
  • Future account-directed email, including email notifications, uses the primary email. Sign-in, password reset, configured-owner matching, and identity correlation continue to accept every verified email.
  • Administrators with permission to view user-management data see the selected primary email in member lists and all verified emails in member details. The API identifies the primary email explicitly; clients do not infer it from address order.
  • Email removal is not available yet.
  • Email verification code issuance is recorded in the EVT audit log with a hashed email, expiry, and safe request metadata; the raw code is not recorded.

Account deactivation

  • An administrator with admin.view-users and user.manage-accounts can deactivate another human account in the member's Account section, next to account deletion. The same administrator can deactivate a bot on the bot's overview page in bot management (FDR-038). The confirmation names the account and explains that access stops but data remains intact.
  • Deactivation blocks password and external-provider sign-in, invalidates cookie and bearer sessions, and closes realtime connections. A replica whose User Auth projection has not applied the deactivation can accept a session for a maximum of 60 seconds (ADR-127). Password resets do not reactivate an account. Existing call connections lose access when the call service next checks participant permissions.
  • The profile, messages, files, room memberships, roles, login, email addresses, and credentials remain stored. The login and email addresses remain claimed. The public profile exposes the deactivation flag. The reason and administrator identity remain private.
  • One-to-one DMs show a notice and disable new messages while the other account is deactivated. History remains readable. User cards retain their usual appearance. New-DM, mention, and invitation pickers omit deactivated accounts. Reactivation restores these controls through realtime status updates without a page reload.
  • A deactivated owner's bots cannot authenticate or exercise permissions. Their data and credentials remain stored.
  • A deactivated bot cannot use its API keys or incoming webhooks. Its realtime connections close. Its data, API keys, and webhooks remain stored.
  • Reactivation permits new sign-ins. Old human sessions and pending sign-in proofs remain invalid. A reactivated bot and the bots of a reactivated owner can use their retained credentials again.
  • Administrators cannot deactivate themselves or owner accounts. Bot owners need user.manage-accounts to deactivate their bots. Repeating the current state has no effect.
  • The feature adds no external service or third-party connection.

Account deletion

  • A human user requests their own deletion via Account Settings.
  • Self-service deletion requires user.delete-self when the user requests a confirmation token and when they use it. If an operator revokes the permission, the user cannot use a token that was created before revocation.
  • An administrator with admin.view-users and user.delete-any can delete another human member from the Account section of the member detail page in Server Administration. A modal shows the member's user card and states what deletion does. The administrator must type the member's login. Chatto does not request the administrator's password or require a fresh credential for this action. The admin page does not offer this action for the administrator's own account or for a bot. Self-deletion stays in Account Settings, and bots follow FDR-038.
  • A two-step confirmation flow asks the user to type a confirmation string before the deletion executes.
  • Account deletion confirmation-token issuance is recorded in the EVT audit log with expiry and safe request metadata; the raw token is not recorded.
  • The account deletion confirmation token itself lives in RUNTIME_STATE under an HMAC-derived key with a 15-minute per-key TTL.
  • On deletion, the server: records UserKeyShreddingRequestedEvent with the complete opaque key coordinates, immediately tombstones the user's profile, authentication, search, and authored message state, then idempotently shreds app-owned DEK refs from RUNTIME_STATE and KMS wrapping-key refs from ENCRYPTION_KEYS. UserKeyShreddedEvent records physical completion. Durable workers retry unfinished key shredding and current message-owned asset deletion facts across crashes and replicas.
  • Account deletion does not close the realtime connections of other users. The server sends UserAccountDeletedEvent for the key-shredding request, after its room timeline has the tombstones, and again for the account-deletion fact. A resume across these facts delivers the same events and does not select a snapshot. UserKeyShreddedEvent changes no client state and is not sent. Each client discards its copies when it gets the event: the profile, and the content of each loaded message of that user. The bundled client makes those messages tombstones at once, applies the same rule to later rows of that user, clears loaded file and pin lists, and reads its loaded timelines again. A client that does not do this keeps content that it already shows until it loads the timeline again.
  • After deletion, all messages the user ever posted are tombstoned by projection before decryption and cryptographically unreadable. Timeline clients apply the normal deleted-message retention rule, so placeholders without current attachments, previews, reactions, or thread replies disappear immediately. A DM with a deleted participant keeps these placeholders and shows a notice that the other user has been deleted (FDR-007).
  • Deleting an account removes its notification list, notification read and visibility boundaries, and push subscriptions. Push-credential cleanup retries from the durable account-deletion fact across crashes and partial failures. Occurrences caused by the deleted account retain no copied profile PII; current actor hydration may disappear without exposing the deleted identity.
  • Historical room join and leave facts remain stored, but timeline messages omit deleted users from membership activity. Grouped activity includes only visible actors, and the row is hidden when none remain.
  • The deleted account leaves its channel rooms and calls, but stays a participant of its DMs. The other participant keeps the conversation and sees the account as a deleted user, not as a self-DM. See FDR-007.
  • New durable user events store login, display name, and verified email as encrypted PII payloads. Projections retain those encrypted envelopes, decrypt login/email transiently to derive in-memory lookup digests and decrypt fields for reads, and remove user-owned lookup entries when the account is crypto-shredded.
  • The login is freed up for re-use.
  • Bots cannot use the human account-deletion flow. Their owner or a human or bot caller with bot.manage deletes them through BotService; deleting a human owner also deletes every bot they own. Those paths use the same durable deletion and crypto-shredding behavior described above.

Design Decisions

1. Verify email before creating a direct-registration account

Decision: Direct registration proves control of the email address before asking for the login and password that complete account creation. The verification code yields a short-lived completion token; only successful completion creates the account and attaches the already-verified email. Why: This avoids durable half-created accounts, prevents unverified users from occupying login names, and ensures every directly registered account begins with a usable recovery address. Generic code-request responses avoid turning the flow into an account-enumeration endpoint. Tradeoff: Direct registration requires working email delivery before the user can choose credentials or enter the application. A lost or expired code restarts the verification step instead of leaving an account that can be resumed.

2. Multiple verified emails per user

Decision: A user can attach multiple verified email addresses. The first address becomes the primary email, and only an explicit user action changes that selection. Account-directed delivery uses the primary email. Every verified email continues to count for configured-owner matching, password resets, and identity correlation. Why: People have work and personal addresses, change jobs, or have an alias. Single-email accounts force needless friction during transitions. Multiple email addresses also help the owners.emails config — operators can list either an old or new email and the right user gets owner status. Tradeoff: The data model and resolvers have to handle a list and a durable selection, not a scalar. The primary selection references the original verified-email event so it does not duplicate user PII.

2a. Confirm new addresses before sending

Decision: Account Settings requires two matching entries of a new email address before it requests a verification code. The dialog says that Chatto will send a verification code to the address. Why: A second entry catches common typing errors before email leaves the server. This reduces failed deliveries and messages sent to unintended recipients, which can cause spam reports. Tradeoff: Adding an email requires one more input step.

2b. Workflow tokens in runtime state

Decision: Registration and email-verification codes, registration completion tokens, password-reset tokens, and account-deletion confirmation tokens are stored in RUNTIME_STATE under HMAC-derived keys with per-key TTLs. The HMAC input is scoped by workflow and keyed by [core].secret_key. Why: These values are raw credentials or credential-adjacent workflow state. They need restart and restore survival, but they are not reconstructable account history and should not become event-log or backup secrets. The audit value is captured separately in safe EVT facts. Tradeoff: Operators must keep [core].secret_key stable across restores if pending account workflows should continue working. Changing it intentionally invalidates outstanding registration, email-verification, password-reset, and account-deletion credentials.

2c. Bind email management to the loaded account

Decision: Each email-management operation asserts the account identity that the client has loaded. The server rejects the operation before it reads or changes email state if the authenticated account is different. Why: Browser cookies are shared across tabs. Signing in to another account in one tab must not let a stale tab read or change that account's private email state. Tradeoff: A stale tab can show an account-changed error and require a refresh before email management continues.

3. Deliberate deletion confirmation

Decision: Self-service deletion requires the user to type a confirmation phrase, not only click a button. Administrator deletion requires the administrator to type the target member's exact login. The requestAccountDeletion mutation sets up the self-service flow, and deleteMyAccount completes it. Why: Deletion is irreversible because the encryption key is destroyed and messages cannot be recovered. The typed value reduces accidental deletion and makes the administrator confirm the correct target. It is a user-interface safety measure, not authentication proof or protection against script execution in the trusted origin. Tradeoff: The additional step makes deletion slower. This is acceptable for an irreversible action.

4. Crypto-shredding instead of message deletion

Decision: Account deletion first appends UserKeyShreddingRequestedEvent at the exact user-aggregate tail; a concurrent key mutation conflicts and retries the request. Account deletion aborts if the request cannot be made durable. Projections treat that request as the immediate fail-closed privacy boundary. The request path and a shared durable worker reconstruct affected key refs from the user's immutable DEK-generation facts and surviving runtime DEK records, shred every wrapping key before deleting any DEK record, and then record physical completion with UserKeyShreddedEvent. Message-owned assets, including derivative children such as thumbnails and video variants, receive AssetDeletedEvent and have their backing bytes removed. Why: Scanning every JetStream stream and KV bucket for a user's messages would be slow, error-prone, and leave fragments in backups and replicas. Recording deletion intent before irreversible work removes the crash window where keys could be gone without a tombstone fact. The user aggregate already provides a narrow durable index of the affected DEKs, and KEK-first deletion keeps current wrapping refs rediscoverable across retries without duplicating storage coordinates in the request event. Backups specifically exclude the encryption key bucket so that restoring a backup doesn't restore the ability to read deleted users' messages. See ADR-007. Tradeoff: Encrypted-but-unreadable message bytes linger forever. Storage cost is small for text; binary assets are explicitly deleted because signed URLs could otherwise keep serving blobs until expiry. A deployment must upgrade all request-serving replicas before using the new deletion protocol and cannot safely roll back once request facts exist.

5. Per-user KEKs, not shared keys

Decision: Each user has their own KEK, addressed through an opaque KMS key ref. New messages use a purpose-scoped message-body DEK epoch stored under an opaque app-owned content-key ref and wrapped by that key ref; durable user PII uses a separate user-PII DEK epoch. Legacy messages encrypted directly with the per-user key remain readable. Why: Shared keys would mean one user's deletion can't crypto-shred their messages without affecting others. Per-user KEKs make each deletion fully self-contained, while opaque key refs, content-key refs, and purpose-scoped DEK epochs keep message and user events compact and map cleanly to local DEK storage plus external KMS unwrap flows. See ADR-007. Tradeoff: Message-body and user-PII decryption have to resolve and unwrap the relevant DEK epoch. The built-in KMS path is cheap and local today; an external KMS may need caching policy and latency budgets.

6. Durable user PII is encrypted, not indexed in EVT

Decision: New durable user events encrypt login, display name, and verified email fields with the user's active user-PII DEK epoch. User and mentionable projections decrypt login/email transiently while applying events to derive normalised in-memory lookup digests, then discard the plaintext. They retain ciphertext for read hydration; no lookup digest is persisted in EVT. Why: Immutable event logs are the wrong long-term home for plaintext PII. Keeping the encrypted payload in EVT preserves replayability without a separate PII KV store, and deletion destroys the key needed to rebuild the data. See ADR-007. Tradeoff: Projection replay and reads need access to key-unwrapping and may incur KMS latency, mitigated by request-scoped DEK reuse during reads. If a user's key is gone, cold replay intentionally cannot rebuild their PII or uniqueness indexes.

7. KMS service boundary, even though it's in-process

Decision: KEK creation, DEK wrapping/unwrapping, and KEK shredding go through a KMS service interface (createKey, wrapContentKey, unwrapContentKey, shredKey) using opaque key refs rather than direct KEK access or user IDs. DEK record create/load/shred stays in application-owned RUNTIME_STATE storage. Why: A clean KMS boundary is what makes future extraction to Vault / AWS KMS / HSM possible without turning the external KMS into Chatto's DEK registry. Keeping wrapped DEKs in RUNTIME_STATE also preserves them in normal data backups without backing up the KEKs needed to unwrap them. See ADR-007. Tradeoff: A tiny indirection layer for what's currently an in-process call. Legacy direct-key body decrypt still has a local raw-KEK compatibility path until old bodies age out.

8. Login is freed on deletion

Decision: After account deletion, the deleted user's login is available for re-use by a new signup. Why: Holding usernames forever would gradually exhaust the namespace. Re-use is acceptable because the new owner gets a new identity (new user ID, new encryption key) — they don't inherit any of the previous user's data or messages. Tradeoff: Old @mentions of the previous user may visually point at the new user once the login is reclaimed. The underlying mention link is to the user id, which is gone; the rendering falls back to plain text.

Permissions

  • Self: an authenticated human user can update their own profile (FDR-022), add verified emails, select a primary email, and delete their own account.
  • user.delete-any — admin permission to delete other users' accounts.
  • user.manage-accounts — deactivate or reactivate another human account.
  • user.delete-self — gates a human user's own-account deletion. Granted to everyone by default; operators can revoke it to lock down self-deletion. Bots cannot exercise it even if an allow appears in their direct permission matrix.
  • ADRs: ADR-007 (per-user encryption with crypto-shredding), ADR-060 (application-neutral data cryptography), ADR-069 (explicit durable consumer lifecycle), ADR-076 (notification occurrences), ADR-077 (persistent notification list)
  • FDRs: FDR-001 (Roles & Permissions), FDR-012 (Notifications), FDR-013 (Web Push Notifications), FDR-022 (User Profile), FDR-023 (Authentication & Sessions), FDR-038 (Bot Accounts)

Open Questions

  • Should deletion also offer anonymization (keep messages, remove identity)? Deactivation preserves both messages and identity.

Records that name this record

Esc