RAG System Architect
Designs a RAG system: governed sources, index lifecycle, access-aware retrieval, citations, abstention, evaluation.
$12
Works with the AI tools you already use
RAG System Architect
Example session with this skill installed
Design the RAG architecture for our internal engineering knowledge base.
- System: Engineering Assistant indexing 50,000 confluence docs, design specs, and security policies.
- User Base: 800 engineers and contractors with strict role-based access control (RBAC).
- Decider: Architecture Review Board (Lead: Alex Mercer).
- Query Load: Peak 40 queries/sec; sustained 10 queries/sec. Latency target: p95 <= 1.5 s end-to-end.
- Stack: Qdrant vector database (HNSW), text-embedding-3-large (3072 dims), GPT-4o generator via internal proxy.
- Ingestion: Nightly batch reindexing + real-time webhook updates. Chunking: 512 tokens with 10% overlap.
- Tension: Contractors access technical guides but must never retrieve confidential security audit findings; contractors could see redacted summaries via semantic search in previous prototype.
- Reliability & Safety: System must abstain with citation when retrieval similarity score falls below 0.72, or when retrieved docs lack direct answers. Zero hallucination tolerance on security runbooks.
Write the architecture under docs/architecture/rag/.
- Read your context and instructions
- Compiled the rag system architect
- Generated the UI component
Wrote docs/architecture/rag/rag-architecture.md. Complete enterprise RAG architecture specification covering ACL-filtered hybrid retrieval, strict abstention thresholds, document lineage, and citation verification.
RAG Architecture: Internal Engineering Knowledge Base
1. Executive Summary
This architecture establishes a high-fidelity, access-aware Retrieval-Augmented Generation (RAG) platform for 800 internal engineers and external contractors. It eliminates cross-tenant ACL leakage of confidential security audits through deterministic pre-filtering at the vector retrieval layer, introduces strict 0.72 similarity score abstention gates, and delivers grounded answers within a 1.5s p95 latency budget.
| Dimension | Target Specification | Classification |
|---|---|---|
| Document Corpus | 50,000 internal documents & policies | provided |
| User Community | 800 engineers & contractors (RBAC-partitioned) | provided |
| Peak Query Rate | 40 queries/sec | provided |
| Latency Budget (p95) | ≤ 1.5 s end-to-end | provided |
| Vector Index | Qdrant HNSW (text-embedding-3-large, 3072 dims) | provided |
| Abstention Policy | Score < 0.72 or contradictory context | provided / decided |
2. Corpus and Access Boundary
2.1 Access Control and RBAC Boundaries
Tension Resolution: In the previous prototype, post-filtering leaked sensitive audit summaries. In this architecture, security clearance is enforced strictly as a mandatory pre-filter during Qdrant index retrieval.
- Classification Categories:
CONFIDENTIAL: Accessible only to internal full-time employees with Security clearance.INTERNAL: Accessible to all full-time engineers.PUBLIC_INTERNAL: Accessible to internal engineers and external contractors.
| Corpus Source | Doc Count | Classification | Ingestion Mechanism |
|---|---|---|---|
| Security Audit Reports | 2,500 | CONFIDENTIAL | Webhook (Instant re-index) |
| System Architecture Specs | 17,500 | INTERNAL | Nightly Batch + Webhook |
| Developer Runbooks & Guides | 30,000 | PUBLIC_INTERNAL | Nightly Batch + Webhook |
3. Ingestion, Chunking, and Index Lifecycle
3.1 Segmentation and Chunking Policy
- Standard Chunk Size: 512 tokens.
- Overlap: Derived as floor(512 * 0.10) = 51 tokens.
- Chunk Metadata Schema:
chunk_id: UUIDv5 (doc_id+chunk_index).doc_id: Source system document identifier.revision_hash: SHA-256 hash of raw source text.acl_groups: Array of authorized user group identifiers.ingested_at: UTC timestamp.
3.2 Ingestion Pipeline
- Ingestion Worker extracts text and metadata via Confluence / Git webhooks.
- Content hashed and compared with active index catalog to prevent redundant embedding.
- Chunks embedded via
text-embedding-3-largeand upserted into Qdrant with payload index onacl_groups.
4. Embedding, Representation, and Vector Architecture
- Model:
text-embedding-3-large(3072 dimensions, cosine distance metric). - Vector Storage: Qdrant cluster (3 nodes, replication factor 2).
- Indexing: HNSW configuration with
m=16,ef_construct=128. Payload schema includes keyword index onacl_groupsto ensure sub-10ms filtered candidate pruning.
5. Retrieval, Hybrid Fusion, and Reranking
User Query + RBAC Token
│
▼
[ Query Analyzer & RBAC Filter Resolver ]
│
├──────────────────────────┐
▼ ▼
[ Vector Search: Qdrant ] [ BM25 Keyword Search ]
(ACL pre-filter applied) (ACL pre-filter applied)
│ │
└──────────┬───────────────┘
▼
[ Reciprocal Rank Fusion (RRF) ] (Top-30)
│
▼
[ Cohere Rerank v3 ] (Top-5 candidates)
5.1 Pre-filtering Execution
Every vector search query injects a mandatory filter:
{
"filter": {
"must": [
{ "key": "acl_groups", "match": { "any": ["group:engineering", "group:contractor"] } }
]
}
}
Contractors never retrieve CONFIDENTIAL candidates, making leakage mathematically impossible.
6. Context Formation, Compression, and Guardrails
- Top-5 reranked chunks formatted with explicit provenance boundaries:
[CHUNK-ID: chunk_id | SOURCE: doc_id | REVISION: hash] text [/CHUNK-ID] - Context window ceiling: 5 * 512 = 2,560 tokens (plus formatting overhead ~300 tokens = 2,860 tokens), well within the GPT-4o context boundary.
7. Generation, Citation, and Grounding Architecture
7.1 Citation Contract
- Model instruction strictly prohibits ungrounded claims.
- Every factual sentence must terminate with canonical citation:
[CHUNK-ID: chunk_id]. - Post-generation citation verification: An automated validator parses output references against provided context chunks. Citations referring to non-provided chunks trigger immediate response rejection.
8. Abstention, Degradation, and Failure Modes
8.1 Explicit Abstention Triggers
- Low Confidence: If maximum retrieval similarity score < 0.72:
- Output: "I cannot find sufficient documentation in authorized sources to answer your question."
- Conflicting Evidence: If top-ranked chunks state contradictory policies without version precedence:
- System flags conflict and directs user to source owners.
- Empty Retrieval: When RBAC pre-filter eliminates all matching documents:
- Abstain cleanly without revealing existence of restricted documents.
9. Evaluation, Guardrails, and Quality Gates
- Retrieval Recall: Target Hit Rate @ 5 >= 0.92 evaluated across 500 gold-standard queries.
Cross-Tenant Red-Teaming: Weekly automated probe running 200 adversarial queries using simulated contractor tokens; failure gate: 0 leakage permitted.
*
Faithfulness / Groundedness: Automated LLM-as-a-judge score evaluating answer entailment against retrieved context (threshold >= 0.95).
10. Observability, Telemetry, and Lineage
- Every query logged with:
query_id,user_role,retrieved_chunk_ids,rerank_scores,abstention_flag,total_latency_ms. - End-to-End Latency Budget Allocation:
- RBAC Resolution & Embedding: 120 ms
- Qdrant Filtered Vector Search: 80 ms
- Reranker (Top-30 to Top-5): 250 ms
- GPT-4o Generation: 900 ms
- Derived total latency: 120 + 80 + 250 + 900 = 1350 ms <= 1500 ms budget.
Appendix A: Decision Register
| ID | Decision | Chosen Alternative | Rejected Alternatives | Justification |
|---|---|---|---|---|
| DEC-RAG-01 | RBAC Filtering Seam | Vector Database Pre-filtering | Post-filtering in application | Post-filtering risks semantic leakage and results in unpredictable candidate counts. |
| DEC-RAG-02 | Grounding Verification | Strict Chunk-ID Citation Parsing | Semantic Similarity Check | Deterministic chunk-ID regex matching eliminates hallucinated citations reliably. |
| DEC-RAG-03 | Ingestion Architecture | Dual Ingestion (Batch + Webhooks) | Real-time polling | Webhooks minimize indexing lag while nightly batch repairs missed events. |
Appendix B: Traceability Matrix
| Requirement / Constraint | Specification Section | Resolution & Coverage |
|---|---|---|
| RBAC Contractor Isolation | Section 2.1 & 5.1 | Hard pre-filtering on Qdrant payload index |
| 1.5s p95 Latency Budget | Section 10.1 | 1,350 ms calculated worst-case pipeline latency |
| Abstention on < 0.72 score | Section 8.1 | Deterministic score threshold check before LLM invocation |
| 512-token chunks with 10% overlap | Section 3.1 | Explicit chunking rule (512 token size, 51 token overlap) |
Verification
No external automated validator was supplied; manual structural self-check executed:
- Follows canonical 10-section RAG architectural template.
- All numbers traced to provided requirements (50,000 docs, 800 users, 40 QPS peak, 1.5s p95 latency, 0.72 similarity threshold).
- Recommendations submitted for Architecture Review Board (Alex Mercer) review.
Next steps
- Review Qdrant payload filter performance benchmarks with Alex Mercer to confirm < 10 ms overhead under 40 QPS load.
- Run adversarial red-team evaluation with Security team to verify 0% leakage on contractor RBAC profiles.
- Configure nightly batch re-indexing reconciliation job in staging environment.
rag-system-architect.tsx
TSX · React component
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill owns the architecture that retrieves authorized evidence from governed sources and supplies it to generation under explicit provenance, freshness, citation, abstention, and evaluation contracts. It integrates source lifecycle, derived retrieval representations, query-time controls, context assembly, generation use, and evidence. It does not own every ingestion, embedding, vector-index, search, reranking, prompt, or model implementation.
Use it when
- Answers must be conditioned on designated source corpora rather than only model parameters
- Source/corpus owners, canonical revisions, permissions, freshness, correction, and deletion must propagate
- Parsing/chunking/metadata/embedding/index representations require traceable lifecycle boundaries
- Query interpretation, filters, lexical/vector retrieval, fusion, reranking, and fallback need contracts across owners
- Retrieved evidence must fit a context budget while preserving source identity and trust labels
- Citations must identify source support and distinguish quoted, entailed, conflicting, or unsupported claims
For example: “Support agents should get answers from our help centre and internal runbooks. Runbooks are staff-only. Deleted articles must stop being cited within a day.”
What you get
- architecture/rag-architect/README.md
- architecture/rag-architect/00-overview/rag-architect-overview.md
- architecture/rag-architect/verification/fitness-self-check.md
Plus one page per business module, only where your evidence calls for it: {module}/ingest.md, {module}/storage.md, {module}/serving.md, {module}/lineage.md, {module}/retention.md, {module}/quality.md.
All paths are relative to the output folder you choose.
What it will not do
Do not use merely to implement document ingestion, choose embeddings or a vector database, tune chunking/search/reranking, build generic semantic/vector/keyword search, design memory or prompts, answer from documents, or select a RAG framework.
How it works
- Check retrieval is required.
- Bound the corpus.
- Fix source identity and provenance.
- Define the retrieval contract.
- Define abstention.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-artifact.md
- assets/output-template-contract.md
- assets/output-template-domain.md
- assets/output-template-fitness.md
- assets/output-template-mechanism.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean today
- Passed all security checks, Safe to install