Transport Redis Streams

Harmovela Transport Binding: Redis Streams

> Status: draft. Part of the Harmovela 0.2 transport-redis-streams profile.

Purpose

Define how Harmovela runs over Redis Streams, supporting append-only event logs with consumer-group delivery, per-entry acknowledgement, and entry-ID-based replay.

Framing

Harmovela over Redis Streams stores each Harmovela event as one stream entry:

Entry Fields

XADD entries carry the following fields, in addition to the body field holding the complete JSON-encoded event:

FieldHarmovela FieldType
body(entire envelope)JSON string
aep-typetypestring
aep-sourcesourcestring
aep-sessionsession_idstring
aep-conversationconversation_idstring
aep-tasktask_idstring
aep-correlationcorrelation_idstring
aep-causationcausation_idstring
aep-delivery-modedelivery.modestring

Flat fields let consumers route or filter without deserializing body.

Stream Key Mapping

Harmovela contextRedis stream keyExample
Type pattern task.*aep.type.<type>aep.type.task.progress
Source agent:researcheraep.source.<source>aep.source.agent:researcher
Sessionaep.sess.<session_id>aep.sess.sess_01
All eventsaep.eventsSingle-stream deployment

The default stream prefix is aep. Implementations should allow per-envelope stream routing or a single-stream deployment with field-based filtering.

Redis Cluster

In Redis Cluster, a stream key hashes to one slot. To co-locate related events on the same node, use hash tags in the stream key (e.g., aep.{task_01}.type.task.progress). Entries within a single stream are always totally ordered by entry ID.

Delivery Modes

Harmovela Delivery ModeRedis Streams Mechanism
best_effortXADD with MAXLEN capped; consumers read the tail with XREAD and do not track a group
at_least_onceConsumer group with XREADGROUP; XACK only after Harmovela event.acknowledged is emitted
replayableConsumers store a cursor entry ID and replay with XRANGE/XREAD from that ID

At-Least-Once

Replayable

Consumer Groups

Harmovela sessions map to Redis Stream consumer groups:

SessionConsumer Group
sess_01aep-sess_01
(no session)aep-default
Multiple agents sharing a sessionSame group — entries distributed across members
Independent sessionsSeparate groups — each receives the full stream

Groups are created with XGROUP CREATE <key> <group> $ MKSTREAM (or 0 to consume history).

Ordering

Entries within a single stream key are totally ordered by entry ID:

Session Lifecycle

Redis StateSession State
Consumer created, group joined (XGROUP CREATECONSUMER)CREATED
First XREADGROUP returns assignmentOPENED
First entry consumedREADY
Consumer deleted (XGROUP DELCONSUMER)CLOSED
Consumer idle beyond claim timeoutERROR

Implementation Notes

References