Your organization has knowledge scattered everywhere: docs, wikis, Slack conversations, emails, databases. Your AI agents need access to it. But you can’t let every agent access every document (security, privacy). I built Socratic-knowledge: enterprise RAG (Retrieval-Augmented Generation) with multi-tenancy, role-based access control, versioning, and audit logging. Agents retrieve exactly the knowledge they need. Users stay secure.
The Problem: Knowledge Is Fragmented and Dangerous
Scenario 1: The Scattered Knowledge
Your organization has knowledge in:
Wikis (internal documentation)
Google Drive (design docs, strategy docs)
GitHub (code docs, architecture)
Slack (Q&A conversations, decisions)
Email (historical decisions, context)
Databases (product specs, configurations)
PDFs (whitepapers, research)
Your agents need this knowledge to make good decisions.
But it’s fragmented. Inconsistent. Sometimes contradictory.
Your agent searches the wiki for product specs. Gets outdated info. Your agent searches email for decision history. Gets 500 unrelated emails. Your agent searches Slack. Finds someone’s joke mixed with actual information.
Agents make bad decisions because they have bad knowledge.
Scenario 2: The Security Nightmare
You have sensitive knowledge:
Customer data
Financial information
Proprietary algorithms
Personal conversations
Some agents need access (customer support agent needs customer data). Other agents shouldn’t (recommendation engine shouldn’t see financial data). Users need to control what’s shared (customer shouldn’t see other customer’s data).
Without access control, either:
You don’t share knowledge (agents are dumb)
You share everything (security breach)
Scenario 3: The Versioning Problem
Knowledge changes. Your product specs are updated. Your strategy shifts. Your processes evolve.
Which version should the agent use?
The current version? (might break compatibility with old customers)
The version from when the agent was trained? (might be outdated)
All versions? (agent gets confused by contradictions)
Without versioning, agents work with stale knowledge.
Scenario 4: The Compliance Burden
You need to know:
Which agent accessed which knowledge?
When did it access it?
What decisions did it make based on that knowledge?
If a decision was wrong, which knowledge led to it?
Without audit logging, you have no compliance trail.
Why Standard RAG Fails for Multi-Tenant Systems
Standard RAG
Standard RAG (Retrieval-Augmented Generation):
Store all knowledge in a vector database
When agent needs knowledge, search the database
Return top matching documents
Agent uses documents to make decisions
This works for single-tenant systems. It breaks for multi-tenant:
Problem 1: Access Control
Anyone with access to the RAG system can retrieve any knowledge
No way to restrict based on role or tenant
Problem 2: Data Isolation
All data is mixed together
One tenant’s knowledge bleeds into another’s
Problem 3: Versioning
Documents are static
No way to track multiple versions
Problem 4: Audit Trail
No logging of who accessed what
No compliance trail
The Solution: Socratic-Knowledge
Socratic-knowledge is an enterprise RAG system built for multi-tenant environments.
Core Features
Feature 1: Multi-Tenancy
Complete data isolation between tenants:
Organization A:
├─ Documents (completely isolated)
├─ Knowledge base (separate)
├─ Agents (can only access org A knowledge)
└─ Users (can only see org A)
Organization B:
├─ Documents (completely isolated)
├─ Knowledge base (separate)
├─ Agents (can only access org B knowledge)
└─ Users (can only see org B)
System enforces: Organization A agents NEVER see Organization B documents
Feature 2: Role-Based Access Control (RBAC)
Fine-grained permissions:
Roles within Organization A:
Admin:
├─ Can view all documents
├─ Can edit all documents
├─ Can grant/revoke access
└─ Can view audit logs
Manager:
├─ Can view team documents
├─ Can edit team documents
├─ Can grant access to team
└─ Can view team audit logs
Employee:
├─ Can view shared documents
├─ Cannot edit
├─ Cannot grant access
└─ Cannot view audit logs
Example: Customer Support Agent
├─ Can access: Customer data, product docs, policies
├─ Cannot access: Financial data, employee records, future roadmap
└─ Can only see data for assigned customers
Feature 3: Document Versioning
Track changes over time:
Product Specification Document
Version 1 (Jan 2026):
├─ SKU: 123
├─ Price: €49.99
├─ Description: "Widget v1"
└─ Status: Active
Version 2 (Mar 2026):
├─ SKU: 123
├─ Price: €59.99 (updated)
├─ Description: "Widget v1.5" (updated)
└─ Status: Deprecated
Version 3 (May 2026):
├─ SKU: 456
├─ Price: €69.99 (new product)
├─ Description: "Widget v2"
└─ Status: Active
Agent using version 3 gets current info.
Legacy system using version 2 still works.
Historical queries can use historical versions.
Feature 4: Audit Logging
Complete compliance trail:
Audit Log:
2026-05-14 10:30:00 | RecommendationAgent | Retrieved | "Customer Preferences v2"
2026-05-14 10:30:15 | RecommendationAgent | Generated | "Recommendation 123"
2026-05-14 10:31:00 | UserNotificationAgent | Retrieved | "User Preferences"
2026-05-14 10:31:30 | UserNotificationAgent | Retrieved | "Marketing Policies"
2026-05-14 10:32:00 | AnalyticsAgent | Retrieved | "Sales Metrics (restricted)"
↑
Agent accessed restricted doc
System flagged as access denied
Query Audit Trail:
├─ Who accessed? RecommendationAgent
├─ When? 2026-05-14 10:30:00
├─ What did they access? Customer Preferences v2
├─ Which agent? ID: agent_456
├─ For which customer? Customer ID: cust_789
└─ Did they have permission? Yes (role: recommendation_engine)
Feature 5: Semantic Search
Find knowledge by meaning, not keywords:
Query: "How do we handle complaints?"
Traditional search matches:
├─ "complaint form" (keyword match)
├─ "complaints process" (keyword match)
└─ "customer complaints" (keyword match)
Semantic search understands meaning:
├─ "customer support escalation" (related meaning)
├─ "complaint resolution procedure" (related meaning)
├─ "unhappy customer handling" (semantic equivalent)
└─ "issue resolution framework" (underlying concept)
Returns more relevant results.
Finds knowledge agent wouldn't find with keywords.
Feature 6: Vector Embeddings
Store knowledge in a way that’s searchable and meaningful:
Document: "Our product is fast and reliable"
Traditional storage:
├─ Search for "fast": Found (keyword match)
├─ Search for "quick": Not found (different word)
└─ Search for "performance": Not found (synonym not used)
Vector embedding:
├─ Converts to vector: [0.23, -0.45, 0.89, ...]
├─ Search for "fast": Found (semantic similarity)
├─ Search for "quick": Found (semantic similarity)
└─ Search for "performance": Found (semantic similarity)
Agent searches for "How responsive is our product?"
System finds "Our product is fast and reliable"
Even though no exact words match.
Real Examples
Example 1: Customer Support
Customer support agent helps users:
Agent: CustomerSupportAgent
Permissions:
├─ View: Customer data, product docs, support policies
├─ Cannot: View financial data, employee records
└─ Data scope: Only assigned customers
Query: "User asks: 'How do I reset my password?'"
Agent retrieves:
Search knowledge base: "password reset"
Found documents (in order of relevance):
"Password Reset Procedure v5" (current)
"Troubleshooting: Can't Reset Password" (related)
"Security: Password Requirements" (related)
Agent uses documents to respond to user.
Audit trail:
├─ Time: 2026-05-14 14:32:00
├─ Agent: CustomerSupportAgent
├─ Documents accessed: 3
├─ Customer: cust_123
└─ Outcome: User helped with password reset
System tracks: For compliance, debugging, improvement
Example 2: Policy Enforcement
Recommendation agent must follow policies:
Agent: RecommendationAgent
Permissions:
├─ View: Product specs, customer preferences, pricing
├─ Cannot: View employee data, internal discussions
└─ Data scope: All products, assigned customer
Query: Agent generates recommendation
Knowledge retrieval:
Product: "Widget v2"
Spec: €69.99
Availability: In stock
Policy: "No recommendations for out-of-stock items"
Customer preferences: "Likes blue products"
Agent generates recommendation respecting:
├─ Product specs (accurate pricing)
├─ Policies (follows rules)
└─ User preferences (personalized)
If policy changes, next query uses new policy.
No code change needed.
Example 3: Historical Context
Agent needs context from the past:
Query: "Why did we stop using AWS?"
Retrieves:
Version 1 (Jan 2026): "AWS Evaluation: Good for scaling"
Version 2 (Mar 2026): "AWS Issues: Cost overruns"
Version 3 (May 2026): "AWS Decision: Switch to GCP"
With versions, agent can understand:
What we thought originally
What changed (cost overruns)
What decision we made (switch)
Why (cost)
Historical context enables better decisions.
Implementation: Setting Up Knowledge Management
Step 1: Create Tenant and Knowledge Base
from socratic_knowledge import KnowledgeManager
km = KnowledgeManager()
Create organization (tenant)
org = await km.create_organization(
name="Acme Corp",
id="org_123"
)
Create knowledge base for organization
kb = await km.create_knowledge_base(
organization_id="org_123",
name="Acme Knowledge Base"
)
Step 2: Define Roles and Permissions
Define role: Customer Support Agent
support_role = await km.create_role(
organization_id="org_123",
name="customer_support",
permissions={
"view": ["customer_data", "product_docs", "support_policies"],
"edit": ["support_tickets"],
"cannot_view": ["financial_data", "employee_records"]
}
)
Assign role to agent
await km.assign_role(
agent_id="support_agent_1",
role_id="customer_support",
organization_id="org_123"
)
Step 3: Upload Documents
Upload document
doc = await kb.upload_document(
title="Password Reset Procedure",
content="...",
version="5.0",
access_level="public"
)
Upload sensitive document
sensitive = await kb.upload_document(
title="Employee Compensation",
content="...",
version="1.0",
access_level="restricted",
allowed_roles=["admin", "hr"]
)
Step 4: Agent Retrieves Knowledge
Agent searches with permissions enforced
results = await kb.search(
query="How do we handle customer complaints?",
agent_id="support_agent_1", # Permissions checked
organization_id="org_123" # Tenant isolated
)
Returns only documents agent has access to
for result in results:
print(f"- {result.title} (v{result.version})")
Automatically logged for audit trail
Step 5: View Audit Trail
Check who accessed what
audit = await km.get_audit_log(
organization_id="org_123",
document_id="doc_456",
time_range=(start_date, end_date)
)
for entry in audit:
print(f"{entry.timestamp}: {entry.agent_id} accessed {entry.document_id}")
The Philosophy: Knowledge Should Be Trustworthy
Agents are only as good as the knowledge they’re given.
Socratic-knowledge ensures knowledge is:
Accurate (versions ensure you know which version you’re using)
Appropriate (access control ensures agents only see what they should)
Traceable (audit logging ensures you know where decisions came from)
Secure (multi-tenancy ensures data stays isolated)
With trustworthy knowledge, agents make trustworthy decisions.
Use Socratic-Knowledge for Enterprise RAG
The enterprise knowledge management system described in this post is production-ready and open source:
GitHub: https://github.com/Nireus79/Socrates
PyPI Package: https://pypi.org/project/socratic-knowledge/
Documentation: https://github.com/Nireus79/Socrates/tree/main/socratic-knowledge
Quick Start
Install the knowledge system
pip install socratic-knowledge
from socratic_knowledge import KnowledgeManager
km = KnowledgeManager()
Create knowledge base
kb = await km.create_knowledge_base(organization_id="org_123")
Upload documents
await kb.upload_document(
title="Product Specs",
content="...",
version="1.0"
)
Agent retrieves with permissions
results = await kb.search(
query="product specifications",
agent_id="agent_1",
organization_id="org_123"
)
for result in results:
print(f"- {result.title}")
Full examples and documentation: https://github.com/Nireus79/Socrates
The Complete Socratic Ecosystem
Socratic-knowledge is part of the complete Socrates AI system (11 modules, 2,300+ tests):
Socratic-nexus: Multi-provider LLM client
Socratic-morality: Constitutional governance with 13 modules
Socratic-agents: Multi-agent orchestration with conflict resolution
Socratic-knowledge: Enterprise RAG with multi-tenancy(this post)
Socratic-learning: Self-improving agents
Socratic-analyzer: Code quality analysis
Socratic-performance: Real-time monitoring
Socratic-workflow: Workflow orchestration
Socratic-conflict: Conflict resolution between agents
Socratic-docs: Auto-documentation
Socratic-maturity: Project maturity tracking
All modules work together seamlessly. Use individual packages or the complete platform.
Available on PyPI under MIT License: https://pypi.org/user/Nireus79/