How lucas1114/rag-contract works
rag-contract is a fixed-corpus question-answering service whose contract emphasizes attributable answers, explicit refusal states, measured retrieval quality, versioned indexes, and enforced budgets. The request path runs through the HTTP surface and Service, which acquires one index, retrieves passages, drafts claims, and grounds them into an answer. Separate evaluation and gate paths check retrieval, answer behavior, index freshness, and thresholds. Edges reflect excerpts, SOURCE INDEX references, or README statements; unsampled details are omitted where wiring cannot be verified.
Main entry points: service.py Request Service · index.py Committed Index · cli.py Command Line · lifecycle.py Index Lifecycle
Components 25
Corpus and Index
- RFC Corpus
corpus - Corpus Loader
src/rag_contract/corpus.py - Section Parser
src/rag_contract/sections.py - Section Chunking
src/rag_contract/chunking.py - Embeddings
src/rag_contract/embedding.py - Committed Index
src/rag_contract/index.py - Index Lifecycle
src/rag_contract/lifecycle.py - Index Registry
src/rag_contract/registry.py
Answering
- HTTP Surface
src/rag_contract/app.py - Request Service
src/rag_contract/service.py - Vector Retrieval
src/rag_contract/retrieval.py - Claim Drafter
src/rag_contract/drafter.py - Claim Grounding
src/rag_contract/grounding.py - Answer States
src/rag_contract/answering.py
Evaluation and Gate
- Question Annotations
src/rag_contract/evalset.py - Retrieval Evaluation
src/rag_contract/evaluate.py - Answer Evaluation
src/rag_contract/answer_eval.py - Quality Gate
src/rag_contract/gate.py - Command Line
src/rag_contract/cli.py
Runtime Controls
- Request Budgets
src/rag_contract/budget.py - Rate Limiter
src/rag_contract/ratelimit.py - API Spend Cap
src/rag_contract/spend.py
Other components
- Questioner
- Embedding API
- Drafting API
Connections 36
- Questioner → HTTP Surface: asks
README.md - HTTP Surface → Request Service: delegates
src/rag_contract/app.py - Request Service → Index Registry: acquires index
src/rag_contract/service.py - Request Service → Vector Retrieval: searches
src/rag_contract/service.py - Request Service → Claim Drafter: drafts claims
src/rag_contract/service.py - Request Service → Answer States: forms answer
src/rag_contract/service.py - Answer States → Claim Grounding: checks claims
src/rag_contract/answering.py - Vector Retrieval → Committed Index: ranks vectors
src/rag_contract/retrieval.py - Claim Drafter → Drafting API: optional request
src/rag_contract/drafter.py - Embeddings → Embedding API: embeds text
src/rag_contract/embedding.py - Corpus Loader → RFC Corpus: loads and verifies
src/rag_contract/corpus.py - Section Parser → Corpus Loader: parses documents
src/rag_contract/sections.py - Section Chunking → Section Parser: chunks sections
src/rag_contract/chunking.py - Committed Index → Corpus Loader: fingerprints corpus
src/rag_contract/index.py - Committed Index → Section Chunking: stores chunks
src/rag_contract/index.py - Index Lifecycle → Corpus Loader: checks corpus
src/rag_contract/lifecycle.py - Index Lifecycle → Embeddings: checks model
src/rag_contract/lifecycle.py - Index Lifecycle → Committed Index: checks version
src/rag_contract/lifecycle.py - Index Registry → Committed Index: loads index
src/rag_contract/registry.py - Question Annotations → Answer States: validates states
src/rag_contract/evalset.py - Retrieval Evaluation → Question Annotations: scores questions
src/rag_contract/evaluate.py - Retrieval Evaluation → Vector Retrieval: measures ranking
src/rag_contract/evaluate.py - Answer Evaluation → Answer States: evaluates outcomes
src/rag_contract/answer_eval.py - Answer Evaluation → Claim Grounding: checks grounding
src/rag_contract/answer_eval.py - Quality Gate → Request Budgets: checks ceilings
src/rag_contract/gate.py - Quality Gate → Index Lifecycle: checks freshness
src/rag_contract/gate.py - Command Line → Retrieval Evaluation: runs evaluation
src/rag_contract/cli.py - Command Line → Answer Evaluation: runs answer eval
src/rag_contract/cli.py - Command Line → Quality Gate: runs gate
src/rag_contract/cli.py - Command Line → Committed Index: builds index
src/rag_contract/cli.py - Command Line → Claim Drafter: records drafts
src/rag_contract/cli.py - Request Budgets → Rate Limiter: defines limit
src/rag_contract/budget.py - HTTP Surface → Rate Limiter: limits requests
src/rag_contract/app.py - Request Service → Request Budgets: enforces deadline
src/rag_contract/service.py - Embeddings → API Spend Cap: accounts usage
src/rag_contract/embedding.py - Claim Drafter → API Spend Cap: accounts usage
src/rag_contract/drafter.py