Transport Nats

Harmovela Transport Binding: NATS

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

Purpose

Define how Harmovela runs over NATS, supporting subject-based publish/subscribe with optional JetStream durability.

Framing

Harmovela over NATS uses JSON-encoded Harmovela events as NATS message bodies:

Subject Mapping

Harmovela topics map to NATS subjects using a configurable prefix:

Harmovela contextNATS subject patternExample
Topic tasks.task_01aep.tasks.task_01aep.tasks.task_01
Source agent:researcheraep.agent.researcheraep.agent.researcher
Wildcard subscription task.*aep.task.>aep.task.>
Session-scopedaep.sess.<session_id>aep.sess.sess_01

The default subject prefix is aep. Implementations should make this configurable.

Subject Construction

PatternBehavior
aep.type.<type>Route by event type (e.g. aep.type.task.progress)
aep.source.<source>Route by event source
aep.topic.<topic>Route by explicit Harmovela topic
aep.sess.<session_id>Route to all events for a session
aep.conv.<conversation_id>Route to all events for a conversation

Producers should publish on the most specific subject. Consumers subscribe with wildcards.

Delivery Modes

Core NATS (Best Effort)

JetStream (At Least Once, Replayable)

Delivery Mode Selection

Harmovela Delivery ModeNATS Mechanism
best_effortCore NATS publish
at_least_onceJetStream push consumer with AckWait
replayableJetStream pull consumer with DeliverPolicy

Session Lifecycle

NATS StateSession State
Connection establishedCREATED
First subscription createdOPENED
Capability negotiation completeREADY
Connection drain + closeCLOSED
Connection lost (no reconnect)ERROR

Connection

The transport should support:

Implementation Notes

Core NATS

JetStream

References