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.

Memory Schema

Each stored memory is a row in the ForgeMemory table with the following key fields:

FieldTypePurpose
embeddingvector(1536)Noisy embedding for semantic search
encryptedContenttextAES-256-GCM encrypted memory content
ivtextRandom initialization vector (12 bytes)
authTagtextGCM authentication tag (16 bytes)
tenantIdtext (NOT NULL)Tenant isolation boundary
tqScorefloatTrust Quotient score (0.0–1.0)
intenttextIntent category from validation
epsilonfloatDP privacy budget used
sanitizedbooleanWhether 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)