Add the optional messaging module: connectors, API, agent connection, console #91
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "messaging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
An optional messaging module (
/messaging/v1,KARTA_MESSAGING=1, off by default) for conversations over WhatsApp and SMS: connectors, conversations, messages and files; an HTTP API (send with an idempotency key, read, check a recipient, upload files, connectors, settings); signed webhook events; the remote-connector WebSocket for Postduif (postduif.v1: one-time code enrolment, Ed25519 proof on connect, commands with acknowledgements, events with cursors applied exactly once, resume, several replicas with or withoutKARTA_CLUSTER); console pages (connectors, an archive of conversations searched by number, settings); retention (default 730 days, per organisation; sign-in codes 7 days at most); messages encrypted at rest; metrics; guides.This is milestone 3 of the plan. The Bird SMS plug (M4) and fallback routing with the guard rails (M5) follow in their own pull requests.
Off means off
With the module off Karta behaves as before: every
/messaging/v1path and every messaging page answers as an unknown route, no menu entries, no new API key scope, no webhook event choices, no Oban queue or cron job, no PromEx plugin, no process. The migration only adds new tables (nothing existing is altered). Tested intest/karta_web/messaging/off_test.exs.Webhooks
Messaging events are a separate list (
Catalogue.messaging_types/0). A webhook with no event list receives no messaging event; it must name them. Tested inwebhook_events_test.exs. The v2 webhook OpenAPI enum now lists the messaging types (accepted byPOST/PATCH /api/v2/webhooks).Protocol
The contract is
postduif-protocol.md(copy inprotocol/). I implemented it exactly and appended a dated "Proposed change 1" (12 clarifications: fingerprint algorithm, key encoding, host in the proof, what is resent on resume, ack over gaps,byebefore close, ...) to the original, without a version bump.Tests
154 tests and 3 properties in the messaging suites: a real WebSocket test double of the agent (
test/support/messaging/test_agent.ex) covers enrol, connect, inbound events (redelivery, out-of-order cursors, history), send, acknowledgements, statuses, a connection that drops mid-command and resumes, replacement, revocation, heartbeats, back-pressure; plus the API, tenancy, retention (blob before row), console, OpenAPI and off-state suites.mix format,mix credo --strict,mix compile --warnings-as-errorsandmix docsare clean.Not proven
No real Postduif has connected (the test double speaks the contract as written). WebSocket behind Traefik is standard Bandit WebSock and was not run here. The notes for enabling it on live are in
docs/suite/release-1.0/karta-messaging.md.🤖 Generated with Claude Code