Delivery

How clients receive a conversation: subscriptions, snapshots, ordered frames, cursors, reads after a cursor, and resnapshot.

Subscribing

{"id": "2", "op": "subscribe", "body": {"conversation_id": "conv_…"}}

Without a cursor, the server answers with a snapshot. With a cursor that it can still serve, it answers with an acknowledged resume and then sends the missing frames.

{"type": "snapshot", "cursor": {"projection_id": "view_conv_…", "epoch": "e1", "sequence": 47},
 "conversation_version": 1, "state": [], "timeline": {"events": []}}

A snapshot is the view at cursor. Apply it first, then apply frames whose sequence is greater than cursor.sequence.

Resuming after a disconnect A client resumes from its cursor after a disconnect. If the cursor has expired, the server asks for a resnapshot, and the client subscribes again without a cursor. Client Server Journal B connection drops; subscriptions end turn finishes: 51 to 53 F discard the old view; apply the snapshot A subscribe, cursor 47 frames 48 to 50, up_to_date C initialize, then subscribe cursor 50 D is cursor 50 still served? no: the log was trimmed push resnapshot_required, cursor_expired E subscribe, no cursor snapshot at cursor 53 frames after 53 as they happen
A client that falls behind resumes from its cursor. When the cursor can no longer be served, it subscribes again from a snapshot.

Frames

A frame places one event at one position:

{"type": "frame", "cursor": {"projection_id": "view_conv_…", "epoch": "e1", "sequence": 48},
 "event": {"event_id": "evt_…", "type": "robotelos.message", "…": "…"}}

Rules, which every client MUST follow:

  1. Frames arrive in sequence order.
  2. Sequences are contiguous. A client that receives 48 after 46 MUST NOT apply 48; it MUST read the missing position or resubscribe.
  3. A frame with a sequence the client already has MUST be ignored. This makes redelivery safe.
  4. A frame of a different epoch means the journal was rebuilt. The client MUST resnapshot.

Frames are sent to the transport in batches as frames pushes. A batch is only a transport detail: every frame keeps its own cursor, and up_to_date: true marks the point where the client has caught up with the journal.

Reading after a cursor

{"id": "3", "op": "read_after", "body": {"conversation_id": "conv_…", "cursor": {…}, "limit": 50}}

The result carries frames, the new cursor, and up_to_date. When the cursor cannot be served, the result carries resnapshot_reason instead of frames.

Resnapshot

A server MUST demand a resnapshot, rather than send a gap, when:

ReasonCauseClient action
cursor_expiredThe cursor is older than the server keepsSubscribe with no cursor
epoch_changedThe journal was rebuiltSubscribe with no cursor
removedThe participant left or was removed from a groupStop; the conversation is closed for this principal

In a push, the server sends resnapshot_required with the reason. A client MUST discard its view for that conversation before it applies a new snapshot.

Several connections

A principal may hold several connections, and each one has its own subscriptions. The server sends the same frames to every subscription of a conversation, in the same order. A receipt goes only to the connection that sent the command.

Slow clients

A client that cannot keep up with frames SHOULD bound its queue. The Go SDK does this: a full queue returns ErrSlowConsumer, and the client resumes from its last checkpoint instead of losing events. The server keeps the events, so nothing is lost.

Disconnects

A disconnect ends the subscriptions of that connection. It does not cancel work, and the events that work produces are recorded. A client resumes from its cursor on the next connection.

Next steps