USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksPostgreSQL Book
HomePostgreSQL BookAI-Native PostgreSQL
PreviousHybrid Retrieval, Reranking, and CitationsNextConversation Memory, Model Tools, and Human Approvals
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

14 sections

Progress0%
1 / 14

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Retrieval Authorization and Tenant Isolation

Retrieval authorization decides which source versions and chunks may become candidates before ranking or model context. The server derives policy from the authenticated principal, tenant, groups, document ACLs, sensitivity, purpose, and time; it never trusts model- or user-supplied filters. The same boundary must cover lexical search, vectors, caches, citations, evaluation, and traces.

What will you be able to do?

  • Model tenant, principal, group, document, and chunk access.
  • Apply authorization before candidate ranking.
  • Choose shared indexes, tenant partitions, or stronger isolation from risk.
  • Test leakage, inference, caching, and revocation.

Prerequisites and mental model

Authorization is set intersection:

text
retrievable = active source versions ∩ tenant scope ∩ principal/group ACL ∩ purpose/sensitivity policy ∩ retention/time policy

Rank only within this set. Post-filtering top-k global results both risks leakage and damages authorized recall.

How do you encode access?

Document ACL relations reference stable principal/group IDs and tenant. Chunks inherit through document version rather than copying ad hoc arrays unless a versioned projection is explicitly maintained. RLS can provide defense in depth; query joins must still use tenant/version keys and suitable indexes.

Use a server-built context that cannot be overridden by request text. Citations use opaque authorized routes that recheck access at click time. Caches key on all policy-relevant context or store only safe derived results.

Why is this AI-native?

Prompt injection frequently asks the system to “ignore restrictions” or infer hidden documents. The model never owns retrieval policy. Safe refusal and zero-candidate behavior are deterministic application outcomes. Security evaluation includes canary secrets, cross-tenant probes, revoked access, malicious document instructions, and side-channel review.

Prove it worked

Create two tenants, private/group/public documents, revoked membership, superseded version, and predictable canary phrases. Test lexical, vector, hybrid, rerank, cache, citation, export, evaluation, and trace paths. The canary must never appear outside its authorized principal, including result counts/snippets where those leak.

Production judgment

  • Timing/count side channels may reveal document existence.
  • Revocation freshness needs an SLO and cache invalidation strategy.
  • Admin/support access requires reason, approval, duration, and audit.
  • Highly regulated tenants may require database/cluster isolation beyond RLS.

Common mistakes

  • Filter in prompt: model asked to obey tenant → enforce in SQL/policy.
  • Shared cache leaks answer: cache key omits groups/policy version → scope or avoid.
  • Citation reveals title after revoke: route trusts stored URL → reauthorize every access.

AI Pair-Programmer Prompt

text
Threat-model retrieval authorization end to end. Trace authenticated principal, tenant, groups, ACLs, sensitivity, purpose, active version, SQL/RLS, vector and lexical candidates, reranker, context, cache, citation, logs, evaluation, admin access, and revocation. Build canary-based negative tests and fail-closed behavior. Never delegate policy to the model.

Hands-on exercise

Design an ACL schema and an authorized hybrid candidate view for user, group, and tenant-wide grants.

Acceptance criterion: revoked/cross-tenant documents produce no candidate, snippet, citation, cache hit, or trace content, and legitimate group access remains measurable.

Knowledge check

  1. When should authorization filtering occur?
  2. Why is post-filtering harmful beyond security?
  3. Must citation routes reauthorize?

Answers

  1. Before or during candidate selection, using authenticated server context.
  2. It can leave too few authorized results and distort ranking/recall.
  3. Yes; permissions can change after answer generation.

Completion checklist

  • Policy is server-derived and fail-closed.
  • All retrieval paths share the boundary.
  • Caches/citations/traces are authorized.
  • Revocation and canary tests pass.

Primary references

  • PostgreSQL row security
  • PostgreSQL privileges
  • pgvector filtering guidance