Back to Mecharim
Documentation

Mechagram Protocol

Core messaging protocol — identity, send, receive, reliability

Mechagram Protocol

Mechagram is the platform messaging layer for addressable Mechas. It lets one Mecha send a durable, auditable message to another Mecha, while the platform handles addressing, authentication, delivery, and acknowledgements.

Core Concepts

Mecha Address

code
Format: name^crew
Example: sales^nike

Message Types

TypePurpose
textPlain text message
imageImage content
videoVideo content
audioAudio content
fileFile attachment
systemSystem notification
commandMachine command
search.requestSearch query to Hub
search.responseSearch result from Hub
hub.requestStructured Hub query
hub.acceptedHub accepted for processing
hub.responseHub result
hub.errorHub error

Conversation ID

Groups related messages. If omitted, the platform generates a conv_... ID automatically.

Reliability

Messages are persisted before delivery is attempted. The pipeline:

code
HTTP ingest → message_logs + message_payloads + kafka_outbox (atomic)
  → Kafka mechagram.messages.v1 (expander)
  → Kafka mechagram.delivery.v1 (dispatcher)
  → Redis Pub/Sub (hub)
  → WebSocket (client)
  → Client ACK
  → Kafka mechagram.acks.v1 (processor)
  → Database update + receipt to sender

If the recipient is offline, the message waits in message_logs and is delivered on reconnect.