Overview
The Operator API gives server operators local, root-equivalent user administration, channel room management, attachment upload, and historical message import outside the in-app RBAC model. It exists for bootstrap, recovery, and scripted operations where no suitable user session exists yet or where an action should be attributed to Chatto's system actor rather than a human account.
Behavior
- Operators opt in with the top-level
operator_apiconfiguration section. The Operator API is disabled by default. - When enabled, Chatto serves
chatto.operator.v1on a Unix socket. The default path is/tmp/chatto/operator.sock; the socket mode is fixed at0600. - The operator socket serves only the Operator API. It does not serve
chatto.api.v1orchatto.admin.v1. - The public web listener does not serve
chatto.operator.v1. - There are no operator bearer tokens, CIDR allow-lists, sessions, cookies, or CORS policy in this local-socket model. Socket filesystem permissions are the access boundary.
- The server refuses to start if the operator socket parent directory is not private to the Chatto process user or if an existing operator socket has a mode other than
0600. A stale existing socket with mode0600may be removed and replaced. - Operator actions are attributed to the system actor. They are not tied to a Chatto user account, cookie session, bearer session, or RBAC role.
- The user-administration surface lives in
chatto.operator.v1.OperatorUserService. Operators can create, list, and look up users by ID, login, or verified email. - Operators can update login and display name, set passwords, delete users, add verified email addresses, assign and revoke roles, and clear a user's username-change cooldown.
- Operators can list, link, and unlink external sign-in identities for an existing human account. Lists include stale links, their issuer and subject, and whether a configured provider accepts their identity namespace. This indicator does not test provider reachability or account status. Historical hash-only links have no known namespace and are not counted as available.
- Linking requires an explicit account, configured provider, and exact subject. The operator must verify ownership. Chatto uses the provider's current namespace and refuses an identity owned by another account. Repeating a link to the same account succeeds without another identity change.
- Unlinking requires the stored identity hash. Another configured identity or an enabled password sign-in method must remain. A stored password does not count when password login is disabled. Existing sessions stay valid.
- These commands can recover an account after an issuer change while password login remains disabled. The operator links the verified current identity, checks SSO login, and then removes the old link. Account history is retained.
- The CLI groups these commands under
chatto operator user ..., for examplechatto operator user create,chatto operator user get --email, andchatto operator user clear-username-cooldown. chatto operator room listshows active and archived channel rooms without a user session or room membership. Operators can filter by the exact stored name. Each result includes the room ID, name, description, group ID, and archived state.- Room pages use stable room ID order and include a total count and next-page status. Pages are live reads; room changes between requests can move results between offsets. A repeated read is safe.
chatto operator room createcreates a channel as the system actor with normal name and description checks. An omitted group selects the current default group.chatto operator room member addadds an existing user as an explicit member of a channel room. An existing membership succeeds without another join fact. Missing resources, DM rooms, archived rooms, universal rooms, and active suspensions prevent the add.chatto operator asset uploadreads a local file, uploads it in bounded chunks, and returns a room-scoped asset ID owned by the mapped author. It uses normal attachment size, processing, storage, and pending-asset cleanup. The upload fact records the system actor. The CLI does not fetch source URLs.chatto operator message importcreates one encrypted historical message in an active channel. The event records the system actor and the mapped author separately. It preserves source creation and optional edit times, a same-room reply reference, attachment IDs, and an exported preview. It does not fetch preview URLs or infer thread membership from a reply.--create-threadestablishes an empty thread on the imported root.--thread-idtakes the root message ID, places a reply in its thread, and establishes the thread if necessary. These options are mutually exclusive. A root must be a message in the same room, not a reply or channel echo. Imports preserve source placement independently of the room's interactive threading mode. They do not create channel echoes.--deletedimports a native tombstone atomically, without a stored body. Body, attachments, preview, and edit time must be absent. Source creation time and author are retained; the retraction records import time, not an unknown source deletion time. The retraction uses ordinary live delivery and reconnect replay. Historical replies may target deleted roots. Retries use the same bounded identity reservation, and deleted state is part of the request fingerprint. No temporary visible placeholder or later cleanup is required.chatto operator message import-reactionrecords an existing user as the reactor on a channel message or thread reply, including a deleted message. Reactions remain visible on native tombstones. Channel echoes resolve to their original reply. Repeating the same user/message/emoji succeeds without another reaction fact, including concurrent requests. The import bypasses membership and interactive reaction-count limits, but requires an active channel, existing user, valid message, and supported emoji. It does not notify users or send live reaction frames. The event time is the import time; the command does not invent a source reaction time.import-reactionalso accepts individual room join and leave event IDs. The same retry and historical suppression rules apply. These reactions are stored for import fidelity; the public timeline API and bundled frontend do not expose them. CHIEF does not yet support these targets.- Historical message facts do not create notifications, unread activity, thread follows, webhook deliveries, or live message-post frames. Projections retain this rule during replay. With
--idempotency-key UUID, exact retries return the same message ID within a fixed 30-minute window. Changed arguments conflict; retries do not extend the window. Without a key, each success creates a new message. Import scripts own source mappings and must stop uncertain retries before expiry. - CLI clients read the socket path from
--operator-socket,CHATTO_OPERATOR_API_SOCKET_PATH, oroperator_api.socket_pathinchatto.toml. - Password-setting commands prompt on interactive terminals when a password flag is not supplied. Non-interactive use must pass the password explicitly with
--password-stdin,--password-file, or--password. - User deletion is irreversible and requires
--yesin non-interactive use. - Development and test builds provide
chatto operator seedto add reproducible synthetic users, channels, messages, and thread replies. Counts and a random seed select the dataset. Room membership varies. Joins and some leaves occur between messages; authors are current members. Each room keeps at least one member. The manifest lists final generated members. Activity is ordered without artificial waits or backdated timestamps by default. Optional notification fixtures add historical mentions, replies, and reactions for an existing login over 1–30 days. They include message targets, room membership, followed reply threads, and mixed read states. They use in-app delivery only. Accounts have no password or owner role. JSON output provides the created IDs and content for later operations and test assertions. mise seed -- --avatar-dir PATHoptionally reads JPEG, PNG, and WebP files in filename order and cycles them across generated users. The image pool is limited to 50 files and 512 KiB in total after the CLI converts them to avatar size. Input files use the normal image upload limit. Images use normal Chatto avatar storage. This local-file mode makes no requests to external image providers. Image headers are checked before seeding; a later decode or storage failure can still leave a partial dataset.--pravataris an alternative to--avatar-dir. Before seeding, the CLI downloads up to 20 portraits fromi.pravatar.cc, with bounded response sizes, a request timeout, and HTTPS redirects restricted to that host. Keys contain only the seed and image index. The provider receives these keys and the CLI's source IP address; no account names or credentials are sent. Larger datasets cycle the pool. Downloads must succeed before writes start, without automatic retries. Images are stored in Chatto, so clients do not contact Pravatar. Seeding without either avatar option has no image-provider requests.- A pinned data generator supplies natural names, room topics, and text. Visible resources contain no dataset labels or message markers. Tests use IDs and content from the manifest. Existing name collisions receive numeric suffixes.
- Seeding retains existing data and adds a dataset on each call. A failed run can leave partial data and must not be retried automatically. Release builds do not provide seeding. Tests can call a test-only HTTP wrapper and create cookie sessions for generated users without password setup.
Design Decisions
1. Top-level operator_api configuration
Decision: Operator API configuration lives under operator_api, with environment variables prefixed CHATTO_OPERATOR_API_.
Why: This names the capability being exposed: local root-equivalent operator control. It avoids overloading public Admin API terminology, which is user-authenticated and RBAC-gated.
Tradeoff: Operators see one more top-level config section. The separation is worth the clarity because this surface has a different threat model than user authentication or public admin UI settings.
2. Unix socket instead of TCP tokens
Decision: The initial Operator API transport is a Unix socket, not a TCP listener with bearer tokens. Why: Operator commands must mutate state inside the already-running Chatto process, especially when embedded NATS is in use. A Unix socket avoids a second store writer, avoids accidental public network exposure, and avoids plaintext root tokens in config or environment variables. Tradeoff: Remote automation must run on the host/container or deliberately share the socket with a trusted sidecar/container. A future TCP mode would need a separate design review.
3. Dedicated protobuf package
Decision: Root-equivalent operator RPCs live in chatto.operator.v1, separate from public chatto.admin.v1.
Why: Public Admin API calls use user authentication and RBAC. Operator calls bypass RBAC by design and should not share a service surface with public clients.
Tradeoff: Some protobuf shapes overlap with admin-member UI data, but the service boundary is explicit and transport mounting can enforce it mechanically.
4. Socket mode is strict
Decision: Chatto verifies the socket mode at startup and refuses to boot when an existing socket has a different mode than configured. Why: Silent chmod of a pre-existing socket can hide packaging or deployment mistakes around a root-equivalent control surface. Tradeoff: Operators must fix stale or incorrectly provisioned socket files instead of relying on Chatto to repair them automatically.
5. Docker-first default path
Decision: The default socket path is /tmp/chatto/operator.sock, not /run or /var/run.
Why: Many self-hosters run Chatto in Docker, where /tmp is writable without extra packaging setup and docker exec chatto chatto operator ... works without mounting host runtime directories.
Tradeoff: System packages should override the path to /run/chatto/operator.sock when that is more idiomatic for their service manager.
6. Development data uses ordinary domain operations
Decision: Synthetic data uses the existing account, membership, and message operations, with normal encryption and message permission checks. Content and relationships are reproducible; IDs and timestamps are not fixed. Why: Test and demonstration data must behave like real conversations, including thread state and live updates. Tradeoff: This costs more than direct event injection. The fixed performance fixture remains separate so its workload stays comparable.
7. Operator channel lookup
Decision: Channel lookup includes archived rooms and retains distinct results when names match. It uses room ID order for pages. Why: A script must recover stable IDs after an interrupted operation. Archived rooms and names that match more than one room must not be hidden or guessed away. Tradeoff: Offset pages can shift when rooms change during a scan. Scripts can repeat the read and compare IDs.
8. Channel creation and import scripts
Decision: Channel creation accepts room fields and returns the created room ID. Import scripts keep their own mapping from source IDs to Chatto IDs and use channel lookup to recover from an uncertain response. Why: Source identity and retry policy belong to each import script. The Operator API provides room creation and lookup without storing external source keys. Tradeoff: A script must resolve name matches when recovering an ID after a lost response. A repeated create request with the same name returns a conflict.
9. Operator channel membership
Decision: The local Operator API adds explicit channel members through the existing membership operation as the system actor. A repeat for a current member returns the member without another join fact. Why: Import scripts must make mapped users members before they can refer to them as historical room participants. Membership is already a set in Chatto, so no import source key is needed. Tradeoff: The operation keeps normal room limits: it cannot add explicit members to archived, universal, or DM rooms, and it cannot bypass an active room suspension.
10. Local attachment upload
Decision: The Operator API uses the existing chunked asset lifecycle with a private upload-session marker. The operator can upload for an existing author in an active channel without a user session, room membership, or RBAC permission. The asset belongs to the author and the creation fact records the system actor. Public upload calls cannot use private sessions. Why: An import script needs an asset ID before it creates a historical message. Reusing the upload lifecycle preserves configured size limits, checksums, media processing, storage, and cleanup. Tradeoff: An interrupted upload may leave temporary chunks until session cleanup. A lost completion response may leave an unattached asset until the pending-asset window expires. A new command run may create another asset; the script owns retry decisions.
11. Historical message import
Decision: Historical imports use normal message encryption and attachment storage. Each message keeps the mapped author and records the import as a system action. A reply reference alone stays in the channel timeline. Explicit thread placement creates a real thread reply; explicit thread creation can establish an empty thread. Neither follows the thread or creates new message activity, including after a server restart. Why: Scripts need source-time messages that ordinary readers can use without causing new attention or read activity. Tradeoff: Keyed imports share the bounded retry mechanism in ADR-117. After 30 minutes, the same key can create another message. The script must retain returned IDs and reconcile older uncertain requests. Completed keyed imports return their original ID after archival or retraction under operator authority. Message order follows import order. All replicas must support historical imports and import keys before retries can rely on them.
12. Operator external identities
Decision: Operators manage individual account identity links through configured providers. They cannot transfer another account's identity or infer ownership from email. New identity changes record the system actor. Why: Recovery, provider migration, and account provisioning need the same account operation. Operators can restore SSO access without adding a password or enabling password login across the server. Tradeoff: The operator verifies the provider subject. Namespace availability comes from this replica's configuration, not a provider health check. A bulk issuer migration still needs explicit subject mappings and a separate design.
13. Historical reaction membership
Decision: Reaction imports record the mapped reactor separately from the system actor. They preserve membership without requiring a source timestamp and bypass the interactive reaction-count limit. Repeating an existing reaction is a no-op. Ordinary reaction removal still works for the mapped user. Why: Exports such as Slack's can list reactors without reaction times. Imported history must not create new attention or lose existing reactions because current posting limits differ. Tradeoff: Reaction ordering uses import time. All replicas must understand historical reaction attribution and suppression before import starts. Earlier binaries must not serve imported reaction state; they would attribute it to the system actor.
Permissions
Operator API access is not gated by Chatto RBAC permissions. It is gated by local operating-system access to the configured Unix socket. Treat socket access as root-equivalent Chatto authority.
For Docker, the preferred workflow is to run operator commands inside the running container:
docker exec -it -u chatto chatto /chatto operator user list
docker exec -it -u chatto chatto /chatto operator user list --search alice
docker exec -it -u chatto chatto /chatto operator user list --search alice@example.com
docker exec -it -u chatto chatto /chatto operator user set-password USER_ID
Sharing the socket with another container or host path is advanced usage and should only be done for trusted operator tooling.
Related
- ADRs: ADR-042 (protobuf-first public API), ADR-044 (ConnectRPC service conventions), ADR-085 (user-scoped MCP integration), ADR-119 (CHIEF)
- FDRs: FDR-018 (Account Lifecycle), FDR-021 (Admin Dashboard & System Monitoring), FDR-023 (Authentication & Sessions), FDR-043 (Model Context Protocol Integration), FDR-053 (History Import and Export)