---
title: How the RAG flywheel works
description: Corpus-first generation — how every contract accumulates a knowledge base that makes each article cheaper and better grounded than the last.
locale: en
version: 0.2.0
canonical: https://enterium-developer-docs.pages.dev/developers/how-it-works/rag-flywheel/
---

> Documentation index: https://enterium-developer-docs.pages.dev/developers/llms.txt — every page of this portal has a Markdown twin at <route>.md; the frozen API contract is at https://enterium-developer-docs.pages.dev/developers/api/openapi.json.

**The problem:** grounding articles in live web research is expensive and
non-cumulative. Done naively, article #1000 costs exactly as much research
as article #1 — and nothing stops yesterday's generated text from becoming
tomorrow's "source", a feedback loop that laundered hallucinations into
facts.

## Layer 1 — the corpus is the asset

Each contract owns an accumulating knowledge base of **research facts**:
source-attributed claims extracted from real pages, each carrying its claim
value (the number, price, date), provenance, and a status. Generation
retrieves from this corpus first; the corpus persists and compounds across
runs.

```mermaid
flowchart LR
    SRC[Source pages] -- extract --> RF[(Research facts<br/>per contract)]
    RF -- retrieve + ground --> GEN[Generate]
    GEN -- gaps only --> WEB[External research]
    WEB -- new facts --> RF
    GEN --> ART[Published articles]
```

## Layer 2 — corpus-first, external for gaps only

The flywheel invariant: **external research is spent only on what the
corpus lacks or what went stale** (gap ∪ stale), through a single write
seam. The measurable consequence: external calls per article decrease
monotonically as the corpus matures, while grounding quality does not.
That is the flywheel — every article makes the next one cheaper.

## Layer 3 — hygiene: what keeps the corpus trustworthy

A knowledge base that feeds an LLM is a poisoning target, including
self-poisoning. The guards:

- **Ingest gate** — the body of a *generated* article is never accepted as
  ground truth. Only external, source-attributed material enters.
- **Conflict arbitration** — when two sources disagree on a claim, an
  arbiter resolves which value the corpus carries, rather than keeping
  both silently.
- **Freshness classes** — facts age at different speeds (a protocol
  definition vs a price); TTLs are per fact class, and stale facts fall
  out of retrieval until refreshed.
- **Quarantine** — suspicious material is excluded from retrieval, not
  deleted, so hygiene decisions are reversible and auditable.

## Layer 4 — retrieval that earns its citations

Retrieval is hybrid — dense vectors and full-text search fused by rank —
with a **relevance floor**: a fact must clear a similarity threshold to the
article's topic before generation may cite it. Below the floor, the fact
simply isn't offered. This is what keeps "grounded" from degrading into
"decorated with citations".

## Trade-offs

Corpus-first means a *young* contract writes its first articles from a thin
corpus with more external research — the flywheel needs several cycles to
spin up, and the platform accepts that early cost. Hygiene gates also
reject real facts occasionally (a conservative ingest gate is the safe
side of the trade); the remedy is the arbiter and re-ingestion, not
loosening the gate.

## See it in two minutes

Ask the platform's MCP `list_domains` for the `research` domain — the
corpus surface is a first-class API — or read
[Content lifecycle](../../platform/content-lifecycle/) for where
retrieval sits in the article's path.
