Workers¶
The async workers are a core part of the RagLogic AI architecture. They keep indexing and enrichment work off the online query path while still producing the artifacts that the RAG runtime needs in production.
Figure 1: Worker chain¶
flowchart LR
PG[(PostgreSQL acts and subdivisions)] --> CQ[chunk_jobs]
CQ --> CH[Chunking worker]
CH --> PGC[(PostgreSQL chunks)]
CH --> EQ[embed_jobs__preset]
CH --> XQ[extract_jobs]
EQ --> EM[Embedding worker]
EM --> QD[(Qdrant chunks and acts)]
XQ --> EX[Extraction worker]
EX --> NEO[(Neo4j relations and communities)]
EX --> PGS[(PostgreSQL summaries and extraction state)]
Why these workers exist¶
chunking-workermaterializes chunk records from legal text subdivisions.embedding-workerturns chunks and acts into vectors for semantic retrieval.extraction-workerbuilds relationship structure, canonical summaries, and graph communities.
This split matters because each stage has different CPU, memory, I/O, and model requirements. It also allows partial reprocessing without blocking the online chat runtime.
Worker inventory¶
Worker |
Queue(s) consumed |
Main output |
Main code |
|---|---|---|---|
Chunking worker |
|
chunk rows in PostgreSQL; downstream embed/extract jobs |
|
Embedding worker |
preset-specific |
vectors in Qdrant, embedding state in PostgreSQL |
|
Extraction worker |
|
relations in Neo4j, extraction state and summaries, community detection |
|
Queue and job model¶
Queue |
Representative jobs |
Purpose |
|---|---|---|
|
|
fan out or process chunk generation for acts |
|
|
generate embeddings for a specific preset/model |
|
|
build graph relations, summaries, and graph communities |
What each worker really does¶
Chunking worker¶
reads acts and subdivisions from PostgreSQL,
builds chunk rows, including article-level aggregation when enabled,
deletes stale chunk and embedding state on forced reprocessing,
enqueues downstream
embed_actjobs for every indexing-enabled embedding preset,enqueues downstream
extract_actjobs so graph enrichment stays aligned with the latest chunks.
Embedding worker¶
is bound to one embedding preset and one queue at a time,
embeds chunk content into Qdrant chunk collections,
optionally builds one act-level vector for EUR-Lex acts,
persists embedding-state rows in PostgreSQL so missing vectors can be reconciled later,
can re-run
embed_allreconcile on startup when vectors are missing for the active provider/model/vector size.
Extraction worker¶
extracts legal relations for one act and syncs them to Neo4j,
writes or refreshes canonical summaries,
triggers community detection after successful relation extraction,
owns the richest job family because it covers relation extraction, summaries, and graph-level community materialization.
Figure 2: Event-driven handoff¶
sequenceDiagram
participant PG as PostgreSQL
participant CH as Chunking worker
participant EQ as Embed queues
participant EM as Embedding worker
participant XQ as Extract queue
participant EX as Extraction worker
participant QD as Qdrant
participant NEO as Neo4j
PG->>CH: subdivision content
CH->>PG: insert chunks
CH->>EQ: enqueue embed_act per preset
CH->>XQ: enqueue extract_act
EQ->>EM: embed_act
EM->>QD: upsert chunk and act vectors
XQ->>EX: extract_act
EX->>NEO: write relations
EX->>XQ: enqueue summarize_act and build_communities
Reconcile behavior¶
Each worker also has a startup reconcile path so the system can recover from missed jobs or partially indexed data:
chunking can enqueue
chunk_all,embedding can enqueue
embed_allper preset,extraction can enqueue
extract_allandsummarize_all.
That makes the pipeline more resilient than a pure fire-and-forget queue model.
Metrics and operations¶
The workers expose their own Prometheus endpoints and feed the runtime dashboards:
chunking-worker:9109/metricsembedding-worker:9108/metricsextraction-worker:9107/metrics
Operationally, the most useful signals are:
queue depth,
jobs executed and failed,
worker latency histograms,
extraction status and graph-sync state,
embedding backlog versus indexed corpus size.