Agentic-RAG-Platform

ADR-008: RBAC enforced at SQL layer (pre-retrieval filtering)

Context

The system retrieves chunks based on user queries. Many chunks have access restrictions (role-based, project-based, or user-specific). Unauthorized chunks must NEVER appear in retrieval results, citations, or agent reasoning.

Problem

Where to enforce authorization: in the retrieval SQL (pre-retrieval) or in application code (post-retrieval).

Options considered

Option A: Retrieve-then-filter (post-retrieval)

Option B: Pre-retrieval filtering in SQL WHERE clause

Option C: Per-user vector indexes

Decision

Option B: Pre-retrieval filtering in SQL WHERE clause via the rag.access_matches() function.

Rationale

Trade-offs

Consequences

What happens if this component fails?

How would we replace it later?