Part of #2: Add RAG (Retrieval Augmented Generation) with citations
Scope
Implement the context builder that takes reranked chunks and assembles them into a structured context window suitable for LLM consumption.
Details
- Accept top-k reranked chunks with metadata (source, score, position)
- Assemble chunks into a coherent context string with source attribution markers
- Respect token budget constraints (configurable max context tokens)
- Handle chunk overlap and deduplication (adjacent chunks from same document)
- Preserve source metadata for downstream citation tracking
- Order chunks by relevance score within the context window
Context Format
[Source: consensus-guide.md, chunk 3, score: 0.92]
Multi-model consensus uses 3+ AI models to validate outputs...
[Source: arbiter-pattern.md, chunk 1, score: 0.87]
The arbiter/worker pattern distributes tasks across workers...
Acceptance Criteria
Part of #2: Add RAG (Retrieval Augmented Generation) with citations
Scope
Implement the context builder that takes reranked chunks and assembles them into a structured context window suitable for LLM consumption.
Details
Context Format
Acceptance Criteria