⚒️ Redis + Qdrant Integration — Caching & Vector Memory
DITEMPA BUKAN DIBERI — Forged, Not Given.
Purpose
Redis as caching layer for MCP tool registry and session state; Qdrant as vector store for witness embeddings, semantic memory retrieval, and similarity search across federation knowledge.
When to Use
- Caching MCP tool lists, health probes, or computed results (Redis)
- Session state and lease TTL management (Redis)
- Semantic search across witness receipts, seals, or docs (Qdrant)
- Embedding storage for tri-witness evidence vectors (Qdrant)
- Tool/skill discovery via semantic similarity (Qdrant)
When NOT to Use
- Relational data that needs ACID — use
postgres-schema-design
- Append-only immutable records — use
vault999-witness
- File/blob storage — use S3/R2
Constitutional Floor Alignment
| Floor |
Application |
| F1 AMANAH |
Redis keys have TTL; stale cache never blocks fresh reads |
| F2 TRUTH |
Cache headers (stale-while-revalidate) published with every cached response |
| F4 CLARITY |
One cache key naming convention across all organs |
| F11 AUDIT |
Cache misses and evictions logged; Qdrant writes carry provenance |
| F12 INJECTION |
Vector embeddings sanitized before upsert — no prompt injection in stored vectors |
Commands & Patterns
// Redis — tool registry cache with TTL
const CACHE_TTL = 300; // 5 minutes
await redis.set(`tool:${organ}:list`, JSON.stringify(tools), { EX: CACHE_TTL });
// Redis — session state
await redis.set(`session:${sessionId}`, JSON.stringify(session), { EX: 3600 });
// Qdrant — witness collection upsert
const point: PointStruct = {
id: receiptId,
vector: embedding, // 1536-dim from embedding model
payload: {
witness_type: 'tri_witness',
organ: 'geox',
verdict: 'CONSENSUS',
timestamp: Date.now(),
},
};
await qdrant.upsert('witness_receipts', { points: [point] });
// Qdrant — semantic search
const results = await qdrant.search('witness_receipts', {
vector: queryEmbedding,
limit: 10,
with_payload: true,
});
Refusal Surface
- ❌ Redis persistence for critical audit data (use VAULT999)
- ❌ Qdrant as primary data store (vectors + relational in Postgres)
- ❌ Storing secrets or keys in Redis
- ❌ Embedding user PII into Qdrant vectors
- ❌ Cache-aside without invalidation strategy
1---2id: FORGE-redis-qdrant-integration3name: forge-redis-qdrant-integration4version: 1.0.0-2026.07.175description: "Redis + Qdrant integration — caching layer and vector memory for federation semantic search."6owner: A-FORGE7risk_tier: medium8floor_scope: ['F1', 'F2', 'F4']9autonomy_tier: T110capability_tier: fed-agent-subagent11ecology_state: WARM12---1314# ⚒️ Redis + Qdrant Integration — Caching & Vector Memory1516> **DITEMPA BUKAN DIBERI** — Forged, Not Given.1718## Purpose19Redis as caching layer for MCP tool registry and session state; Qdrant as vector store for witness embeddings, semantic memory retrieval, and similarity search across federation knowledge.2021## When to Use22- Caching MCP tool lists, health probes, or computed results (Redis)23- Session state and lease TTL management (Redis)24- Semantic search across witness receipts, seals, or docs (Qdrant)25- Embedding storage for tri-witness evidence vectors (Qdrant)26- Tool/skill discovery via semantic similarity (Qdrant)2728## When NOT to Use29- Relational data that needs ACID — use `postgres-schema-design`30- Append-only immutable records — use `vault999-witness`31- File/blob storage — use S3/R23233## Constitutional Floor Alignment3435| Floor | Application |36|-------|-------------|37| F1 AMANAH | Redis keys have TTL; stale cache never blocks fresh reads |38| F2 TRUTH | Cache headers (`stale-while-revalidate`) published with every cached response |39| F4 CLARITY | One cache key naming convention across all organs |40| F11 AUDIT | Cache misses and evictions logged; Qdrant writes carry provenance |41| F12 INJECTION | Vector embeddings sanitized before upsert — no prompt injection in stored vectors |4243## Commands & Patterns4445```typescript46// Redis — tool registry cache with TTL47const CACHE_TTL = 300; // 5 minutes48await redis.set(`tool:${organ}:list`, JSON.stringify(tools), { EX: CACHE_TTL });4950// Redis — session state51await redis.set(`session:${sessionId}`, JSON.stringify(session), { EX: 3600 });5253// Qdrant — witness collection upsert54const point: PointStruct = {55 id: receiptId,56 vector: embedding, // 1536-dim from embedding model57 payload: {58 witness_type: 'tri_witness',59 organ: 'geox',60 verdict: 'CONSENSUS',61 timestamp: Date.now(),62 },63};64await qdrant.upsert('witness_receipts', { points: [point] });6566// Qdrant — semantic search67const results = await qdrant.search('witness_receipts', {68 vector: queryEmbedding,69 limit: 10,70 with_payload: true,71});72```7374## Refusal Surface75- ❌ Redis persistence for critical audit data (use VAULT999)76- ❌ Qdrant as primary data store (vectors + relational in Postgres)77- ❌ Storing secrets or keys in Redis78- ❌ Embedding user PII into Qdrant vectors79- ❌ Cache-aside without invalidation strategy