Transport Nats

AEP Transport Binding: NATS

> Status: draft. Part of the AEP 0.1 protocol specification.

Purpose

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

Framing

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

Subject Mapping

AEP topics map to NATS subjects using a configurable prefix:

AEP 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 AEP 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

AEP 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