Storage Layer
Synapse Layer uses PostgreSQL with the pgvector extension as its persistent storage engine. Every memory is stored as an encrypted record with a vector embedding for semantic recall.
On this page
Memory Schema
Each stored memory is a row in the ForgeMemory table with the following key fields:
| Field | Type | Purpose |
|---|---|---|
| embedding | vector(1536) | Noisy embedding for semantic search |
| encryptedContent | text | AES-256-GCM encrypted memory content |
| iv | text | Random initialization vector (12 bytes) |
| authTag | text | GCM authentication tag (16 bytes) |
| tenantId | text (NOT NULL) | Tenant isolation boundary |
| tqScore | float | Trust Quotient score (0.0–1.0) |
| intent | text | Intent category from validation |
| epsilon | float | DP privacy budget used |
| sanitized | boolean | Whether content was sanitized |
Vector Indexing (HNSW)
Semantic recall uses pgvector’s HNSW (Hierarchical Navigable Small World) index for approximate nearest-neighbor search on cosine distance:
- Dimensions: 1536 (matches text-embedding-3-small output)
- m parameter: 16 (connections per layer)
- ef_construction: 128 (build-time search width)
- Distance metric: Cosine similarity
Note
HNSW provides sub-linear search time. Recall queries complete in single-digit milliseconds for typical memory volumes.
Encryption at Rest
Memory content is encrypted before being written to the database:
- Algorithm: AES-256-GCM
- IV: Random 12-byte initialization vector per operation
- Auth Tag: 16-byte GCM authentication tag, validated on every read
- Key management: Keys are rotated per environment and never logged
Encryption is applied server-side. The encrypted content, IV, and auth tag are stored as separate columns, enabling independent verification.
Audit Tables
Synapse Layer maintains several audit tables for operational observability:
- ForgeEvent — Fire-and-forget operation log with structured metadata
- CognitiveAudit — Security pipeline audit records
- HealthCheckLog — Health check history with latency metrics
- McpRequestLog — MCP tool invocation logs
- TokenObservation — Token economy metrics for billing observability
Performance Characteristics
- HNSW index provides sub-linear recall time
- Connection pooling with short idle timeouts (max 25 concurrent connections)
- Statement timeout of 5 seconds prevents runaway queries
- Health check probes classify latency: healthy (<500ms), degraded (<2000ms)