Knowledge Management at Scale: Multi-Tenant RAG with RBAC

Knowledge Management at Scale: Multi-Tenant RAG with RBAC

●10 ●23
calendar_today • schedule2 min read

A Shared Knowledge Base with Tenants, Roles and Versions: Socratic Knowledge
Socratic Knowledge is part of an earlier research prototype. It is not maintained as a product. It has not been deployed for real users or reviewed for security, and it should not be used as if it had.
When several teams or organisations share a knowledge base, a few questions come up at once. Who may see which documents? Who changed this, and can it be undone? How do you find the right document by meaning, not only by exact words? socratic-knowledge is a Python library that I wrote to explore those questions in one place.
What it contains
According to its README:

• Tenants: separate knowledge spaces for separate organisations.
• Collections and items: a hierarchy of collections holding documents.
• Roles: Viewer, Editor, Admin and Owner, granted per item or collection.
• Versions: every change creates a version; an item can be rolled back to an earlier one.
• Search: plain text search, and semantic search using embeddings (the optional RAG integration).
• Collaboration: multi-user editing with conflict detection.
• Audit log: a record of changes and access.
• Storage: SQLite by default.
• Integrations: optional adapters for LangChain and Openclaw.

A short example
from socratic_knowledge import KnowledgeManager

km = KnowledgeManager(storage="sqlite", db_path="knowledge.db")

tenant = km.create_tenant(name="Acme Corp", domain="acme.com")
item = km.create_item(

tenant_id=tenant.id,
title="Onboarding",
content="...",
created_by="user_1",

)

results = km.semantic_search(tenant_id=tenant.id, query="how do new staff get access", top_k=5)
history = km.get_version_history(item.id)
Retrieval and permissions: the point that is easy to get wrong
If a search system returns documents by meaning, it must also check, for every result, whether the person asking is allowed to see it. Checking after retrieval is safer than hoping the index only contains permitted documents. In this library the tenant is part of every search call (tenant_id), and permission checks such as can_user_edit exist. I have not had these checks independently tested, so if you build on this idea, test it with a user who must not see a document and confirm it never appears in a result, a snippet or an error message.
Limits

• Role-based access is simple. Real organisations need group membership, inheritance and time-limited access, which this library does not claim to have.
• Embeddings need a model, and sending document text to an outside embedding service is a privacy decision.
• Conflict detection in editing is basic.
• I have not measured performance at any scale.

The code is open source: github.com/Nireus79/Socratic-knowledge, and the package is on PyPI. The RAG part is a separate library, Socratic RAG.

Want more #ai & #agenticai deep dives?

Join 5,951+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

Part 11 of 11 in Socrates-AI

More Posts

Sovereign Intelligence: The Complete 25,000 Word Blueprint (Download)

Pocket Portfolio - Apr 1

Architecting a Local-First Hybrid RAG for Finance

Pocket Portfolio - Feb 25

What Security Teams Want From AI Agents Before They Let Them Act Alone

Tom Smithverified - Nov 18

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

SpeedCurve vs Apogee Watcher: Multi-Tenant Dashboards at Agency Price

ApogeeWatcherverified - Sep 15
chevron_left
1.3k Points • 33 Badges
11Posts
2Comments
5Connections
Building Socrates: Production AI Multi-Agent Platform (37+ modules). Constitutional governance, RAG ... Show more

Related Jobs

View all jobs →

Commenters (This Week)

16 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!