Event Spine Integration and Ingest Job events¶
This ADR documents the integration of NATS JetStream as the fleet's async event spine, wiring it to the backend-core RAG ingest jobs lifecycle.
Status¶
proposed
Decision¶
- Broker & Client: Use NATS JetStream as the inter-service messaging plane. We use the official
nats-pyclient library. - Subjects & Streams:
- Define the
ingeststream mapping to the wildcard subjectingest.*. - Publish three CloudEvent types under the
ingeststream:ingest.queued.v1(subject:ingest.queued): Emitted when a job enters the async indexing queue.ingest.done.v1(subject:ingest.done): Emitted when a job finishes indexing text/images.ingest.failed.v1(subject:ingest.failed): Emitted when a job exhausts all retry attempts.
- Envelope:
- Adhere to the CloudEvents v1.0 standard envelope, sharing the same schema structure as the LLM FinOps and evaluation trace events (
specversion,id,type,source,subject,time,datacontenttype,data). - Idempotency & DBOS Step Boundary:
- In production, we run under DBOS durable workflows. The JetStream publish calls should act as idempotent operations within the workflow context (DBOS
@DBOS.step). - For local development where DBOS is not present, we use standard async loop task scheduling.
- Configuration Guard:
- Event publishing is guarded by
EVENTS_ENABLEDconfiguration setting. It defaults tofalseuntil explicitly enabled via the environment.