Memory Palace
Graph-Based Semantic Memory System. A graph-based semantic memory system that stores, relates, and retrieves knowledge using Neo4j and vector embeddings. Features a custom query language built on the discriminated union specification pattern, a type-safe Cypher query builder with compile-time validation, and integration as an MCP server so Claude.ai can use it as persistent external memory.
General notes
- Clean architecture with enforced layer boundaries: domain → infrastructure → services → api. Protocol-based interfaces for all external integrations
- Extensible query API using discriminated union specification pattern: 12+ composable spec types generating both Python predicates and Cypher WHERE clauses
- Type-safe Cypher query builder with state machine validating clause ordering at construction time
- Integrated as MCP server enabling Claude.ai to use the system as persistent external memory
Construction notes
- Discriminated union specification pattern: MemorySpecification is an Annotated union composable via .and_(), .or_(), .not_(). Each spec generates both Python predicates and Cypher WHERE clauses
- Type-safe Cypher query builder with state machine validating clause ordering at construction time. LiteralString typing throughout for injection safety
- Circuit breaker (CLOSED → OPEN → HALF_OPEN) with exponential backoff for Voyage AI embedding calls. Proper error classification (rate limit → retryable, auth → not)
- Typed error architecture: ApplicationError base with ErrorCode enum, ErrorLevel, typed ErrorDetails models. @with_error_handling decorator with configurable reraise behavior
- Event-driven background processing: DreamJobOrchestrator runs scheduled jobs including salience decay (configurable half-life), DBSCAN topic clustering, and re-indexing
12+ Composable specification types in the query DSL
4-layer Clean architecture with enforced boundaries
MCP Integrated as Claude.ai external memory server
Materials
- Python/FastAPI
- Neo4j
- Voyage AI
- OAuth
- Cloudflare Tunnel
- MCP
- Project
- Hákon Freyr Gunnarsson
- Sheet
- Detail G
- Title
- Memory Palace
- Scale
- N.T.S.
- Rev
- 2026-10