Skip to content

JoseRFJuniorLLMs/NietzscheDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

227 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

NietzscheDB

NietzscheDB Demo

NietzscheDB

The Multi-Manifold Graph Database for AGI

"A system for everyone and for no one."

perspektive.js NPM Version Rust Multi-Manifold GPU TPU


🧠 The Manifesto: Why Nietzsche?

"There are no facts, only interpretations."
— Friedrich Nietzsche, Notebooks, 1886

"If Zarathustra descended from the mountain to announce the Übermensch, NietzscheDB descended from GitHub to announce Non-Euclidean AGI."
Jose R F Junior

"Are you trying to make AGI with boring tables and vectors? I'm going to do it with dynamite and curved geometry."
Jose R F Junior

Standard databases store data as "static facts" in flat, Euclidean spaces. This is a geometric lie. In high-dimensional intelligence, a concept is defined solely by its relationship to others, and its position is relative to the observer's depth of abstraction.

NietzscheDB implements Perspektivismus (Perspectivism) as a database primitive. It abandons the "God's-eye view" of a single flat table for a Multi-Manifold Architecture, where the same piece of knowledge can be viewed through different geometric lenses depending on the cognitive need.


NietzscheDB is powered by perspektive.js, the world's most advanced multi-manifold graph renderer. It serves as the AGI's "retina," allowing you to audit, debug, and explore the internal manifolds of the database at 60fps.

Visual Cortex

Advanced Auditing Tools:

  • Causal Scrubber (Minkowski Time Machine): Scrub through the database history. Watch nodes dissolve and reform as you rewind the chain of causal reasoning.
  • 🔀 Counterfactual UI: Drag-and-drop nodes to create "What-If" hypotheses. Generate ephemeral edges to simulate new realities without mutating the core graph.
  • 🌌 Fractal Viewport: Infinite zoom into the Poincaré boundary. As the brain grows, the renderer streams new subgraphs dynamically (Google Maps for Memory).
  • ⚛️ Probability Clouds: Volumetric GLSL raymarching visualize quantum fidelity and semantic arousal on the Bloch Sphere.

🌎 The 4 Geometric Perspectives

NietzscheDB doesn't just store data; it projects it across four distinct manifolds to solve specific AGI problems:

Lens Geometry Manifold AGI Role
🌌 Hierarchy Poincaré Ball Hyperbolic (K < 0) Abstraction Level: Depth = Generality. Center = Foundation, Border = Detail.
🧭 Logic Klein Model Hyperbolic (K < 0) Reasoning: Semantic paths are straight lines. O(1) collinearity checks.
Causality Minkowski Lorentzian (Flat) Auditability: Light cone filters ensure effect never precedes cause.
⚛️ Synthesis Riemann Sphere Spherical (K > 0) Dialectics: Where thesis and antithesis merge into a shallower, more abstract point.

🚀 Key Features

┌─────────────────────────────────────────────────────────┐
│                                                         │
│           MULTI-MANIFOLD GRAPH DATABASE                │
│    Poincaré · Klein · Riemann · Minkowski              │
│                                                         │
│   · Perspektive.js 0.1.3 native visual cortex          │
│   · Causal Scrubber (Minkowski Time Machine)           │
│   · Counterfactual UI (Speculative Reasoning)          │
│   · Autonomous fractal growth via L-System rules        │
│   · Multi-scale search via hyperbolic heat diffusion    │
│   · Fast Boot (WAL truncation + parallel rayon loading)  │
│   · Active memory reconsolidation during sleep cycles   │
│   · GPU (cuVS) / TPU (PJRT) accelerated vector search   │
│   · Hegelian Dialectic Engine (automated synthesis)     │
│   · Code-as-Data: NQL queries as activatable nodes      │
│   · Schrödinger Edges (probabilistic context collapse)  │
│   · Self-Healing Graph (autonomous structural repair)   │
│   · Graph Learning Engine (pattern detection & hotspots)│
│   · Knowledge Compression (semantic deduplication)      │
│   · Hyperbolic Sharding (Poincaré-aware partitioning)   │
│   · Cognitive Flywheel (unified autonomous feedback)    │
│   · Hydraulic Flow Engine (Constructal + Murray's Law) │
│   · EpistemologyDaemon (Karpathy autoresearch loop)    │
│   · NietzscheLab (autonomous epistemic evolution)     │
│   · Epistemic Metrics (hierarchy/coherence/coverage)  │
│   · ShadowTGC (full TGC on lightweight ShadowGraph)    │
│   · Morning Report (post-sleep discovery summary)      │
│   · NodeLedger (per-action CPU cost tracking)          │
│   · force_evolution MCP tool (LLM mutation bridge)     │
│   · NietzscheEvolve (AlphaEvolve-inspired self-tuning)│
│   · ParameterEvolve (evolutionary HNSW optimization)  │
│   · EnergyEvolve (evolved energy landscape functions) │
│   · CogEvolve (evolved cognitive strategies for EVA)  │
│   · HypothesisEvolve (LLM prompt meta-evolution)     │
│   · React Dashboard via rust-embed (zero external deps)│
│   · Poincaré 3D coords in /api/graph visualization    │
│                                                         │
└─────────────────────────────────────────────────────────┘

NietzscheDB closes the interpretability gap. It allows you to see the abyss — and ensures that when you look into the database, the database (geometrically) looks back at you.


🧠 Neuro-Symbolic Intelligence: Beyond Vectors

NietzscheDB is a Neuro-Symbolic engine. It bridges the gap between neural perception (embeddings/GNNs) and symbolic reasoning (graph topology/Manifolds).

Integrated ML Models:

  • 🕸️ Neural Foundation (GNN): A native Graph Neural Network that learns node representations directly on the hyperbolic manifold, optimized for high-dimensional hierarchical relationships.
  • 🎯 Value Network: A predictive model that estimates the "Energy" and "Will to Power" of nodes, identifying elite concepts and guiding the autonomous pruning process.
  • 🧪 Zero-Data Pipeline: Built-in orchestration to generate synthetic clinical data, distill it through classical algorithms, and train the neural core without external data dependencies.
  • 🌫️ Diffusion Engine: Real-time Pregel-like heat kernel propagation that simulates neural activation across the graph, modulated by emotional valence and arousal.

  • Abstract concepts naturally live near the center of the Poincaré ball
  • Specific memories live near the boundary
  • Hierarchical distance is intrinsic — not encoded, but geometric
  • The knowledge graph grows and prunes itself like a fractal organism
  • The system "sleeps" and reconsolidates its own memory topology
  • An autonomous evolution cycle (Zaratustra) propagates energy, captures temporal echoes, and identifies elite nodes
  • Causal relationships are identified via Minkowski intervals (ds² < 0 = timelike = causal)

It is a fork of YARlabs/nietzsche-db — extended from a hyperbolic HNSW vector database into the world's first multi-manifold graph database with a full graph engine, query language, L-System growth, 4 non-Euclidean geometries, GPU/TPU acceleration, graph algorithms, cluster support, and an autonomous sleep/reconsolidation cycle.


Why EVA Needs This

Problem Standard Vector DB NietzscheDB
Hierarchy Flat — same depth for all Geometric — depth = abstraction level (Poincaré)
Logic/Reasoning Cosine similarity only Multi-manifold (Klein Model) + straight-line semantic paths
Causal Auditability None Minkowski light cone filters (WHY / What-If)
Observability JSON Logs / Dashboards Perspektive.js Visual Cortex (60fps multi-manifold auditing)
Hypothetical Reasoning Manual data cloning Counterfactual UI (ShadowGraph overlays)
Temporal Scrubbing Time filtering Causal Scrubber (Minkowski Time Machine)
Knowledge Growth Static inserts L-System self-organizing fractal growth
Memory Pruning Manual/TTL deletion Hausdorff dimension self-pruning
Consolidation No concept Sleep Cycles (Riemannian reconsolidation)
Conflict Resolution Last-write-wins Hegelian Dialectic Engine (automated synthesis)
Query Language k-NN / SQL / GraphQL NQL (Multi-manifold, Diffusion, Speculative Dream)
Hardware Generic CPU/GPU cuVS (GPU) + PJRT Ironwood (TPU) backends
Integration REST API MCP (Model Context Protocol) + gRPC + REST

Architecture

NietzscheDB is built as a Rust nightly workspace with 42+ crates in two layers:

┌──────────────────────────────────────────────────────────────────────────────┐
│                         NietzscheDB Layer (32 crates)                        │
│                                                                              │
│  Engine:     nietzsche-graph    nietzsche-query     nietzsche-hyp-ops        │
│  AGI:        nietzsche-agi (17 modules, 7K LOC, 123 tests)                  │
│  Growth:     nietzsche-lsystem  nietzsche-pregel    nietzsche-sleep          │
│  Evolution:  nietzsche-zaratustra nietzsche-epistemics                       │
│  Analytics:  nietzsche-algo     nietzsche-sensory                            │
│  Visionary:  nietzsche-dream    nietzsche-narrative  nietzsche-agency        │
│  Neural:     nietzsche-rl       nietzsche-neural    nietzsche-gnn            │
│  Neural ML:  nietzsche-vqvae   nietzsche-embed     nietzsche-mcts           │
│  Wiederkehr: nietzsche-wiederkehr (+ anomaly detector)                       │
│  Infra:      nietzsche-api      nietzsche-server    nietzsche-cluster        │
│  SDKs:       nietzsche-sdk      nietzsche-mcp                                │
│  Accel:      nietzsche-hnsw-gpu nietzsche-tpu       nietzsche-cugraph        │
│  Search:     nietzsche-filtered-knn  nietzsche-named-vectors  nietzsche-pq   │
│  Index:      nietzsche-secondary-idx                                         │
│  Observe:    nietzsche-metrics                                               │
│  Storage:    nietzsche-swartz   nietzsche-media      nietzsche-kafka          │
├──────────────────────────────────────────────────────────────────────────────┤
│                     NietzscheDB Layer (9 crates — fork base)                │
│                                                                              │
│  nietzsche-core   nietzsche-hnsw   nietzsche-vecstore                       │
│  nietzsche-baseserver nietzsche-proto   nietzsche-cli                         │
│  nietzsche-embed  nietzsche-wasm    nietzsche-rsdk                         │
└──────────────────────────────────────────────────────────────────────────────┘

NietzscheDB Foundation (fork base)

The storage and indexing foundation, inheriting all of NietzscheDB v2.0:

  • Poincare Ball HNSW — native multi-manifold nearest-neighbor index. Not re-ranking, not post-processing: the graph itself navigates in non-Euclidean geometry (Poincaré ball with Klein/Riemann/Minkowski projections at query time).
  • mmap Vector Store — memory-mapped, append-only segments (chunk_N.hyp) with 1-bit to 8-bit quantization (up to 64x compression).
  • Write-Ahead Log v3 — binary [Magic][Len][CRC32][Op][Data] format with configurable durability and automatic crash recovery.
  • gRPC API — async Command-Query Separation with background indexing. Client gets OK as soon as the WAL is written.
  • Leader-Follower Replication — async anti-entropy via logical clocks and Merkle tree bucket sync (256 buckets).
  • SIMD Acceleration — Portable SIMD (std::simd) for 4-8x distance computation speedup on AVX2/Neon.
  • Multi-tenancy — namespace isolation per user_id, per-user quota and billing accounting.
  • 9,087 QPS insert performance verified under stress test (90x above original target).
  • WASM — browser-compatible build via nietzsche-wasm with IndexedDB storage.
  • Universal Embeddernietzsche-embed with local ONNX (ort) + remote API support.

NietzscheDB Extensions

Thirty-two new crates built on top of the foundation:

nietzsche-graph — Multi-Manifold Graph Engine

  • Node = NodeMeta (~108 bytes: id, depth, energy, node_type, hausdorff_local, valence, arousal, content) + PoincareVector (embedding, stored separately for 10-25x traversal speedup)
  • PoincareVector with Vec<f32> coords (distance kernel promotes to f64 internally for numerical stability near the Poincare boundary)
  • SparseVector for SPLADE/sparse embeddings: sorted indices + values with O(nnz) dot product, cosine similarity, and L2 norm
  • Edge typed as Association, LSystemGenerated, Hierarchical, or Pruned
  • AdjacencyIndex using DashMap for lock-free concurrent access
  • GraphStorage over RocksDB with 15 column families: nodes, embeddings, edges, adj_out, adj_in, meta, sensory, energy_idx, meta_idx, lists, sql_schema, sql_data, cooldowns, dsi_id, dsi_semantic
  • Own WAL for graph operations, separate from the vector WAL
  • NietzscheDB dual-write: every insert goes to both RocksDB (graph) and NietzscheDB (embedding)
  • Traversal engine (traversal.rs): energy-gated BFS (reads only NodeMeta — ~100 bytes per hop), Poincare-distance Dijkstra, shortest-path reconstruction, energy-biased DiffusionWalk with seeded RNG
  • EmbeddedVectorStore abstraction: CPU (HnswIndex) / GPU (GpuVectorStore) / TPU (TpuVectorStore) / Mock — selected at runtime via NIETZSCHE_VECTOR_BACKEND. Default is Embedded (real HNSW); Mock requires explicit opt-in
  • Multi-Metric HNSW: Cosine, Euclidean, Poincare, and DotProduct distance metrics per collection. Factory routing ensures correct metric type at the HNSW graph topology level
  • KNN metadata filter push-down: MetadataFilter (Eq, In, Range, And) pushed through VectorStore → DynHnsw → HnswIndex with RoaringBitmap pre-filtering for efficient filtered vector search
  • MERGE upsert semantics: merge_node (find-or-create by content), merge_edge (find-or-create by from/to/type) with ON CREATE SET / ON MATCH SET
  • Atomic edge metadata increment: increment_edge_metadata(edge_id, field, delta) for counter patterns (e.g. r.count = r.count + 1)
  • Persistent secondary indexes: create_index(field) / drop_index(field) / list_indexes() with automatic backfill and startup recovery from CF_META registry. NQL executor auto-detects indexed fields for O(log N) scans instead of full table scans
  • Encryption at-rest (encryption.rs): AES-256-CTR with HKDF-SHA256 per-CF key derivation from master key (NIETZSCHE_ENCRYPTION_KEY)
  • Schema validation (schema.rs): per-NodeType constraints (required fields, field types), persisted in CF_META, enforced on insert_node
  • Metadata secondary indexes (CF_META_IDX): arbitrary field indexing with FNV-1a + sortable value encoding for range scans
  • ListStore (CF_LISTS): per-node ordered lists with RPUSH/LRANGE/LLEN semantics, atomic sequence counters
  • TTL / expires_at enforcement: background reaper scans expired nodes and phantomizes them (topology-preserving). CREATE with ttl property auto-computes expires_at
  • NietzscheDB-compatible cache layer: CacheSet/CacheGet/CacheDel RPCs using CF_META with "cache:" prefix, TTL as 8-byte expiry timestamp, lazy-delete on expired reads
  • Per-collection tokio::sync::RwLock concurrency: CollectionManager with DashMap + Arc<RwLock<NietzscheDB>> per collection. Reads proceed concurrently; writes block only the affected collection
  • Full-text search + hybrid (fulltext.rs): inverted index with BM25 scoring, plus RRF fusion with KNN vector search
  • Schrödinger Edges (schrodinger.rs): probabilistic edges with Markov transition probabilities — edges are "superpositions" that collapse at MATCH time. Context-dependent probability boost, per-tick decay, reinforcement learning. Batch collapse/decay operations
  • Valence/Arousal (valence.rs): emotional dimensions on NodeMeta — valence ∈ [-1, 1] (pleasure/displeasure) and arousal ∈ [0, 1] (intensity). Arousal amplifies energy_bias in diffusion_walk() (heat travels faster through emotional memories). Valence modulates Laplacian edge weights in spectral diffusion (matching-polarity edges boost heat conductivity). Includes emotional_gravity(), decay_arousal(), reinforce_emotion()
  • Query Stability & Gas Limits: NQL query execution is protected by a GasTracker to prevent infinite recursion and resource exhaustion. Each node scan, edge traversal, and condition evaluation consumes a portion of the DEFAULT_GAS_LIMIT (50,000 units).

nietzsche-hyp-ops — Multi-Manifold Geometry Engine

Four non-Euclidean geometry modules sharing a single Poincaré storage layer:

Module Geometry Key Operations
poincare (core) Poincaré ball (K < 0) Mobius addition, exp/log maps, geodesic distance, parallel transport
klein Klein disk (K < 0) to_klein/to_poincare, colinearity check O(1), straight-line pathfinding
riemann Unit sphere (K > 0) Spherical midpoint, Fréchet mean, dialectical synthesis/synthesis_multi
minkowski Minkowski spacetime ds² = -c²Δt² + ‖Δx‖², causal classification (Timelike/Spacelike/Lightlike), light cone filter
manifold Normalization layer normalize_poincare/klein/sphere, health checks, safe roundtrip projections

Invariants enforced: Poincaré ‖x‖ < 1.0, Klein ‖x‖ < 1.0, Sphere ‖x‖ = 1.0. Cascaded roundtrip error < 1e-4 after 10 projections. Includes criterion benchmarks.

nietzsche-query — NQL Query Language

Nietzsche Query Language — a declarative query language with first-class multi-manifold primitives. Parser built with pest (PEG grammar). NQL 4.2 "Beyond the Database" extends NQL into a general-purpose data language: FETCH (HTTP client), STREAM (real-time event processing), REGISTER FUNCTION (user-defined functions), ASK...ABOUT (LLM integration), SCHEDULE (cron-style automation), IMPORT (external data sources), CREATE/DROP TYPE (user-defined schemas), HAVING (post-aggregation filtering), INTERSECT/EXCEPT (set algebra), CALL (stored procedures), EXPLAIN ANALYZE (runtime profiling), and JSON path access (->, ->>). NQL 4.0 "The Constructal Update" adds 5 hydraulic-flow functions (BEJAN_CONDUCTIVITY, POISEUILLE_FRICTION, MURRAY_RATIO, NAVIER_STOKES_TURBULENCE, ONSAGER_DISSIPATION), r.conductivity edge field access, ERODE PATH (conductivity boost along shortest path), and INJECT ENERGY statements — making the Hydraulic Flow Engine queryable. NQL 3.1 "PostgreSQL-grade Analytics" adds CTEs (WITH ... AS), Window Functions (ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD with OVER/PARTITION BY), Views, Materialized Views, RETURNING clause, CHECK constraints, UNIQUE indexes, Prepared Statements (PREPARE/EXECUTE/DEALLOCATE), LATERAL subqueries, and Table Partitioning (RANGE/LIST/HASH). NQL 3.0 brought OPTIONAL MATCH, UNION, CASE WHEN, IS NULL/IS NOT NULL, regex matching, EXISTS subqueries, UNWIND, SHORTEST_PATH, COLLECT, 30+ string/math/cast/null built-in functions, and 5 physicist-named cognitive functions. Supports arithmetic SET expressions (n.count = n.count + 1), edge alias property access (-[r:TYPE]-> with r.weight/r.conductivity in WHERE/ORDER BY), CREATE with TTL, DETACH DELETE, and eval_field fallback to node.content/node.metadata for dynamic properties. 155+ unit + integration tests.

Full NQL Reference: docs/NQL.md

Query types:

Type Description
MATCH Pattern matching on nodes/paths with geometric conditions
OPTIONAL MATCH Left-outer-join style pattern — returns NULL for non-matching bindings
CREATE Insert new nodes with labels, properties, and optional TTL
MATCH … SET Update matched nodes' properties (supports arithmetic: n.count = n.count + 1)
MATCH … DELETE Delete matched nodes
MATCH … DETACH DELETE Delete matched nodes and all incident edges
MERGE Upsert nodes/edges (ON CREATE SET / ON MATCH SET)
DIFFUSE Multi-scale heat-kernel activation propagation
RECONSTRUCT Decode sensory data from latent vector
EXPLAIN Return execution plan with cost estimates
UNION / UNION ALL Combine results from multiple queries (with/without dedup)
UNWIND Expand a list expression into individual rows
SHORTEST_PATH Find shortest path between two node patterns
MATCH ELITES Return top-energy elite nodes from the graph
MEASURE TENSION Compute hyperbolic tension between two node patterns
MEASURE TGC Compute Topological Generative Capacity of the graph
FIND NEAREST K-NN search in hyperbolic space with optional namespace
DREAM FROM Speculative graph exploration via heat-kernel diffusion with noise
APPLY/REJECT DREAM Accept or discard dream simulation results
TRANSLATE Cross-modal projection (Synesthesia) via Poincare ball log/exp map
MATCH ... AS OF CYCLE Time-travel query on named snapshots (Eternal Return)
COUNTERFACTUAL What-if query with ephemeral property overlays
CREATE/DROP/SHOW DAEMON Autonomous daemon agents (Wiederkehr)
SHOW ARCHETYPES List shared cross-collection archetypes
SHARE ARCHETYPE Publish elite node for cross-collection discovery
NARRATE Generate human-readable narrative from graph evolution
PSYCHOANALYZE Return evolutionary lineage of a node (creation, connections, energy)
ERODE PATH Boost conductivity along shortest path between two nodes (Constructal)
INJECT ENERGY Inject energy into a target node (Constructal)
WITH ... AS (...) Common Table Expressions — composable named subqueries (NQL 3.1)
ROW_NUMBER/RANK/... Window Functions with OVER (PARTITION BY ... ORDER BY ...) (NQL 3.1)
CREATE VIEW Named stored queries (NQL 3.1)
CREATE MATERIALIZED VIEW Pre-computed cached queries with REFRESH (NQL 3.1)
RETURNING Return data from mutation results (CREATE/DELETE) (NQL 3.1)
PREPARE/EXECUTE Prepared statements with cached execution plans (NQL 3.1)
LATERAL (...) Correlated subquery for top-N per group (NQL 3.1)
ALTER ... CHECK CHECK constraints for data integrity (NQL 3.1)
CREATE UNIQUE INDEX Unique constraints on fields (NQL 3.1)
PARTITION BY Table partitioning (RANGE/LIST/HASH) (NQL 3.1)
HAVING Post-aggregation filtering on grouped results (NQL 4.2)
INTERSECT Set intersection — return rows common to two queries (NQL 4.2)
EXCEPT Set difference — return rows in first query but not second (NQL 4.2)
CALL Invoke stored procedures with arguments and YIELD (NQL 4.2)
EXPLAIN ANALYZE Execute query and return runtime profiling (time, gas, row count) (NQL 4.2)
CREATE/DROP TYPE User-defined schemas with typed fields and constraints (NQL 4.2)
SHOW TYPES List all registered custom types (NQL 4.2)
FETCH HTTP client — GET/POST external APIs with headers, INTO, UNWIND (NQL 4.2)
STREAM Real-time event processing with THROTTLE interval (NQL 4.2)
REGISTER/DROP FUNCTION User-defined functions in NQL or external languages (NQL 4.2)
SHOW FUNCTIONS List all registered UDFs (NQL 4.2)
ASK ... ABOUT LLM integration — query AI models with graph context (NQL 4.2)
SCHEDULE Cron-style query automation with EVERY interval (NQL 4.2)
DROP/SHOW SCHEDULES Manage scheduled query jobs (NQL 4.2)
IMPORT Load external data (CSV, JSON, Parquet) into collections (NQL 4.2)
expr->key / expr->>key JSON path access on content fields (NQL 4.2)
ANY(x IN ... WHERE ...) Existential quantifier over arrays (NQL 4.2)
ALL(x IN ... WHERE ...) Universal quantifier over arrays (NQL 4.2)
-- Hyperbolic nearest-neighbor search with depth filter
MATCH (m:Memory)
WHERE HYPERBOLIC_DIST(m.embedding, $q) < 0.5
  AND m.depth > 0.6
  AND NOT m.node_type = "Pruned"
RETURN m
ORDER BY HYPERBOLIC_DIST(m.embedding, $q) ASC
LIMIT 10

-- Graph traversal: hierarchical expansion
MATCH (c:Concept)-[:Hierarchical]->(child)
WHERE c.energy > 0.7
RETURN child ORDER BY child.depth DESC LIMIT 20

-- IN / BETWEEN / string operators
MATCH (n)
WHERE n.node_type IN ("Semantic", "Episodic")
  AND n.energy BETWEEN 0.3 AND 0.9
  AND n.node_type STARTS_WITH "S"
RETURN n LIMIT 50

-- Aggregation with GROUP BY
MATCH (n)
RETURN n.node_type, COUNT(*) AS total, AVG(n.energy) AS avg_e
GROUP BY n.node_type
ORDER BY total DESC

-- Mathematician-named geometric functions
MATCH (n)
WHERE RIEMANN_CURVATURE(n) > 0.3
  AND HAUSDORFF_DIM(n) BETWEEN 1.2 AND 1.8
  AND DIRICHLET_ENERGY(n) < 0.1
RETURN n ORDER BY RIEMANN_CURVATURE(n) DESC LIMIT 10

-- Multi-hop path traversal (BFS 2..4 hops)
MATCH (a)-[:Association*2..4]->(b)
WHERE a.energy > 0.5
RETURN a, b LIMIT 50

-- Create a new node
CREATE (n:Episodic {title: "first meeting", source: "manual"})
RETURN n

-- Create with TTL (auto-expires after 3600 seconds)
CREATE (n:EvaSession {id: "sess_1", turn_count: 0, ttl: 3600})
RETURN n

-- Arithmetic SET (per-node evaluation)
MATCH (n:EvaSession {id: "sess_1"})
SET n.turn_count = n.turn_count + 1, n.status = "active"
RETURN n

-- Edge alias: access edge properties in WHERE/ORDER BY
MATCH (a:Person)-[r:MENTIONED]->(b:Topic)
WHERE r.weight > 0.5
RETURN a, b ORDER BY r.weight DESC LIMIT 10

-- Update matched nodes
MATCH (n:Semantic) WHERE n.energy < 0.1 SET n.energy = 0.5 RETURN n

-- DETACH DELETE (node + all incident edges)
MATCH (n:EvaSession) WHERE n.status = "expired" DETACH DELETE n

-- Delete expired nodes
MATCH (n) WHERE n.energy = 0.0 DELETE n

-- Time-based queries with NOW() and INTERVAL()
MATCH (n) WHERE n.created_at > NOW() - INTERVAL("7d") RETURN n LIMIT 50

-- EXPLAIN with cost estimates
EXPLAIN MATCH (n:Memory) WHERE n.energy > 0.3 RETURN n
-- → NodeScan(label=Memory) -> Filter(conditions=1) | rows=~250, scan=EnergyIndexScan, index=CF_ENERGY_IDX, cost=~500µs

-- Multi-scale heat-kernel diffusion
DIFFUSE FROM $seed
  WITH t = [0.1, 1.0, 10.0]
  MAX_HOPS 6
RETURN path

-- Dream Queries — speculative exploration
DREAM FROM $seed DEPTH 5 NOISE 0.05
SHOW DREAMS
APPLY DREAM "dream_xxx"

-- Daemon Agents — autonomous graph patrols
CREATE DAEMON guardian ON (n:Memory)
  WHEN n.energy > 0.8
  THEN DIFFUSE FROM n WITH t=[0.1, 1.0] MAX_HOPS 5
  EVERY INTERVAL("1h")
  ENERGY 0.8
SHOW DAEMONS

-- Time-travel via named snapshots
MATCH (n:Memory) AS OF CYCLE 3
WHERE n.energy > 0.5
RETURN n

-- Narrative Engine
NARRATE IN "memories" WINDOW 24 FORMAT json

-- Evolutionary lineage of a node
PSYCHOANALYZE $node_id

-- Emotional memory search (high arousal, positive valence)
MATCH (n:Episodic)
WHERE n.arousal > 0.7 AND n.valence > 0.3
RETURN n ORDER BY n.arousal DESC LIMIT 10

-- Set emotional state on a memory
MATCH (n) WHERE n.id = $id
SET n.valence = 0.8, n.arousal = 0.9
RETURN n

-- ── NQL 3.0 Features ────────────────────────────────

-- OPTIONAL MATCH (left-outer-join)
MATCH (a:Person)
OPTIONAL MATCH (a)-[:KNOWS]->(b)
RETURN a, b

-- UNION — combine two queries
MATCH (n:Semantic) WHERE n.energy > 0.8 RETURN n LIMIT 5
UNION
MATCH (n:Episodic) WHERE n.energy > 0.9 RETURN n LIMIT 5

-- IS NULL / IS NOT NULL
MATCH (n) WHERE n.title IS NOT NULL RETURN n LIMIT 20
MATCH (n) WHERE n.expires_at IS NULL RETURN n LIMIT 10

-- Regex matching
MATCH (n) WHERE n.title =~ "^neuro.*" RETURN n LIMIT 10

-- EXISTS subquery
MATCH (n) WHERE EXISTS { (n)-[:Association]->(m) } RETURN n

-- CASE WHEN expression
MATCH (n) RETURN n,
  CASE WHEN n.energy > 0.8 THEN "elite"
       WHEN n.energy > 0.5 THEN "active"
       ELSE "decay" END AS status
LIMIT 20

-- COLLECT aggregation (returns JSON array)
MATCH (n) RETURN n.node_type, COLLECT(n.energy) AS energies
GROUP BY n.node_type

-- UNWIND list into rows
UNWIND [1, 2, 3] AS x RETURN x

-- SHORTEST_PATH between two nodes
SHORTEST_PATH (a:Concept)-[*..5]->(b:Memory) LIMIT 1

-- MATCH ELITES — top-energy nodes
MATCH ELITES LIMIT 10

-- MEASURE TENSION between node types
MEASURE TENSION (a:Concept), (b:Memory)

-- MEASURE TGC — Topological Generative Capacity
MEASURE TGC

-- FIND NEAREST — hyperbolic k-NN
FIND NEAREST "concept" TARGET $query_vec LIMIT 5

-- String functions
MATCH (n) WHERE UPPER(n.title) = "NIETZSCHE" RETURN n
MATCH (n) RETURN n.title, LENGTH(n.title) AS len, REVERSE(n.title) AS rev LIMIT 10

-- Math functions
MATCH (n) RETURN n, ABS(n.energy - 0.5) AS dist, ROUND(n.depth, 2) AS rounded
MATCH (n) WHERE SQRT(n.energy) > 0.7 RETURN n

-- Cast functions
MATCH (n) RETURN TO_STRING(n.energy) AS e_str, TO_INT(n.depth * 100) AS d_pct

-- COALESCE (first non-null)
MATCH (n) RETURN COALESCE(n.title, n.name, "untitled") AS label

-- Physicist-named cognitive functions
MATCH (n) WHERE BOLTZMANN_SURVIVAL(n) > 0.5 RETURN n
MATCH (n) WHERE HELMHOLTZ_GRADIENT(n) > 0.1 RETURN n
MATCH (a), (b) WHERE LYAPUNOV_DELTA(a, b) < 0.3 RETURN a, b
MATCH (n) WHERE PRIGOGINE_BASIN(n) > 0.5 RETURN n
MATCH (a), (b) RETURN ERDOS_EDGE_PROB(a, b) AS prob

-- ── NQL 3.1 Features (PostgreSQL-inspired) ─────────

-- CTEs (Common Table Expressions)
WITH active AS (
  MATCH (n:Memory) WHERE n.energy > 0.5 RETURN n
)
MATCH (a) WHERE a.energy > 0.1 RETURN a

-- Window Functions
MATCH (n:Memory)
RETURN n.name, n.energy,
  ROW_NUMBER() OVER (ORDER BY n.energy DESC) AS rank,
  RANK() OVER (PARTITION BY n.label ORDER BY n.energy DESC) AS group_rank

-- Views & Materialized Views
CREATE VIEW high_energy AS MATCH (n) WHERE n.energy > 0.8 RETURN n
CREATE MATERIALIZED VIEW top100 AS MATCH (n) RETURN n ORDER BY n.energy DESC LIMIT 100
REFRESH MATERIALIZED VIEW top100

-- RETURNING clause
CREATE (n:Memory {title: "hello", energy: 0.9}) RETURNING n.id

-- Prepared Statements
PREPARE find_hot(float) AS MATCH (n) WHERE n.energy > $1 RETURN n
EXECUTE find_hot(0.7)

-- LATERAL subquery (top-N per group)
MATCH (n:Memory) LATERAL (MATCH (m) WHERE m.energy > 0.5 RETURN m LIMIT 3) AS top3 RETURN n

-- Constraints & Unique Indexes
ALTER COLLECTION memories ADD CONSTRAINT energy_ok CHECK (n.energy >= 0.0)
CREATE UNIQUE INDEX idx_email ON users (content.email)

-- Table Partitioning
ALTER COLLECTION logs PARTITION BY RANGE (created_at)
ALTER COLLECTION events PARTITION BY HASH (id, 8)

-- ── NQL 4.2 Features ("Beyond the Database") ─────

-- HAVING (post-aggregation filter)
MATCH (n:Memory)
RETURN n.label, COUNT(n) AS cnt, AVG(n.energy) AS avg_e
GROUP BY n.label
HAVING cnt > 5 AND avg_e > 0.3

-- INTERSECT / EXCEPT (set algebra)
INTERSECT (
  MATCH (a:Concept) WHERE a.energy > 0.7 RETURN a
) AND (
  MATCH (b:Concept) WHERE b.depth < 0.5 RETURN b
)
EXCEPT (
  MATCH (a:Memory) WHERE a.energy > 0.5 RETURN a
) MINUS (
  MATCH (b:Memory) WHERE b.label = "archived" RETURN b
)

-- CALL stored procedures
CALL pagerank("knowledge_galaxies", 20, 0.85) YIELD node_id, score

-- EXPLAIN ANALYZE (runtime profiling)
EXPLAIN ANALYZE MATCH (n:Memory) WHERE n.energy > 0.5 RETURN n

-- CREATE TYPE (user-defined schemas)
CREATE TYPE Person (name STRING, age INT, email STRING NULLABLE)
SHOW TYPES
DROP TYPE Person

-- JSON path access
MATCH (n) RETURN n.content->"name" AS name, n.metadata->>"version" AS ver

-- ANY / ALL quantifiers
MATCH (n) WHERE ANY(tag IN n.tags WHERE tag = "important") RETURN n

-- FETCH (HTTP client)
FETCH "https://api.example.com/data" WITH HEADERS {"Authorization": "Bearer $token"}
  INTO result UNWIND result.items AS item

-- STREAM (real-time event processing)
STREAM MATCH (n:Episodic) WITH THROTTLE "5s"

-- REGISTER FUNCTION (user-defined functions)
REGISTER FUNCTION normalize(x FLOAT) RETURNS FLOAT LANGUAGE NQL AS "x / ABS(x)"
SHOW FUNCTIONS
DROP FUNCTION normalize

-- ASK ... ABOUT (LLM integration)
ASK "claude-sonnet-4-20250514" ABOUT "summarize the main concepts"
  CONTEXT MATCH (n:Concept) WHERE n.energy > 0.7 RETURN n.title LIMIT 10

-- SCHEDULE (cron automation)
SCHEDULE "cleanup" EVERY "1h" DO MATCH (n) WHERE n.energy < 0.01 DETACH DELETE n
SHOW SCHEDULES
DROP SCHEDULE "cleanup"

-- IMPORT external data
IMPORT "data/nodes.csv" FORMAT CSV INTO my_collection
IMPORT "data/graph.json" FORMAT JSON INTO my_collection

Built-in geometric functions:

Function Named after Computes
HYPERBOLIC_DIST(n.e, $q) Poincare ball geodesic distance
POINCARE_DIST(n, $q) Henri Poincare Same — explicit model name
KLEIN_DIST(n, $q) Felix Klein Beltrami-Klein distance
RIEMANN_CURVATURE(n) Bernhard Riemann Ollivier-Ricci curvature
HAUSDORFF_DIM(n) Felix Hausdorff Local fractal dimension
GAUSS_KERNEL(n, t) Carl Friedrich Gauss Heat kernel exp(-d^2/4t)
CHEBYSHEV_COEFF(n, k) Pafnuty Chebyshev Chebyshev polynomial T_k
DIRICHLET_ENERGY(n) P.G.L. Dirichlet Local Dirichlet energy
EULER_CHAR(n) Leonhard Euler V - E characteristic
LAPLACIAN_SCORE(n) P.-S. Laplace Graph Laplacian diagonal
LOBACHEVSKY_ANGLE(n, $p) N. Lobachevsky Angle of parallelism
MINKOWSKI_NORM(n) H. Minkowski Conformal factor
RAMANUJAN_EXPANSION(n) S. Ramanujan Spectral expansion ratio
FOURIER_COEFF(n, k) J. Fourier Graph Fourier coefficient
NOW() Current Unix timestamp (seconds, f64)
EPOCH_MS() Current Unix epoch (milliseconds, f64)
INTERVAL("1h") Duration to seconds (s/m/h/d/w units)
BOLTZMANN_SURVIVAL(n) Ludwig Boltzmann Survival probability via energy statistics
HELMHOLTZ_GRADIENT(n) Hermann von Helmholtz Free-energy gradient magnitude
LYAPUNOV_DELTA(a, b) Aleksandr Lyapunov Stability divergence between two nodes
PRIGOGINE_BASIN(n) Ilya Prigogine Dissipative structure basin depth
ERDOS_EDGE_PROB(a, b) Paul Erdős Edge formation probability (Erdős–Rényi)
COALESCE(a, b, ...) First non-null value
UPPER/LOWER/TRIM(s) String case/whitespace functions
LENGTH/SUBSTRING/REPLACE String manipulation
CONCAT/REVERSE/SPLIT String composition
ABS/CEIL/FLOOR/ROUND Numeric rounding
SQRT/LOG/LOG10/POW Mathematical functions
SIGN/MOD Sign and modulus
TO_INT/TO_FLOAT/TO_STRING/TO_BOOL Type casting
CASE WHEN ... THEN ... END Conditional expression
COLLECT(expr) Aggregate into JSON array

nietzsche-lsystem — Fractal Growth Engine

The knowledge graph is not static — it grows by L-System production rules:

  • ProductionRule fires when EnergyAbove(t), DepthBelow(t), HausdorffAbove(t), or custom conditions (And, Or, Not, Always)
  • SpawnChild places the child node deeper in the Poincare ball (more specific, closer to boundary) via Mobius addition u + v
  • SpawnSibling creates lateral associations at a given hyperbolic angle
  • Prune archives low-complexity regions (not deleted — tagged as Pruned)
  • Hausdorff dimension computed via box-counting on hyperbolic coordinates at scales [4, 8, 16, 32, 64]
  • Nodes with D < 0.5 or D > 1.9 are pruned automatically; target fractal regime: 1.2 < D < 1.8
  • LSystemEngine::tick protocol: Scan -> Hausdorff update -> Rule matching -> Apply mutations -> Report
  • EnergyCircuitBreaker: cross-system anti-tumor protection — depth-aware energy caps, BFS tumor detection, energy dampening, rate limiting. Prevents runaway energy cascades from creating pathological node clusters
  • 41+ unit tests across all modules

nietzsche-pregel — Hyperbolic Heat Kernel Diffusion

Multi-scale activation propagation across the hyperbolic graph:

  • Chebyshev polynomial approximation of the heat kernel e^(-tL) — O(K x |E|) complexity
  • Hyperbolic graph Laplacian — edge weights derived from Poincare distances
  • Modified Bessel functions I_k(t) for computing Chebyshev coefficients analytically
  • Multiple diffusion scales: t=0.1 activates direct neighbors (focused recall), t=10.0 activates structurally connected but semantically distant nodes (free association)
  • Valence-modulated Laplacian: edge weights incorporate emotional valence — edges between nodes of matching emotional polarity (both positive or both negative) propagate heat faster (emotional clustering effect)
  • HyperbolicLaplacian + apply_heat_kernel + chebyshev_coefficients as stable public API

nietzsche-wiederkehr — DAEMON Agents

Autonomous agents that live inside the database, patrolling the graph and executing actions when conditions are met:

  • DaemonDef with configurable WHEN conditions, THEN actions, EVERY interval, and ENERGY budget
  • DaemonEngine tick loop: evaluate conditions, collect intents, decay energy, reap dead daemons
  • Will to Power priority scheduler: BinaryHeap-based scheduling with energy × urgency weighting
  • NQL: CREATE DAEMON, DROP DAEMON, SHOW DAEMONS
  • 18 unit tests (store, evaluator, engine, priority)

nietzsche-dream — Dream Queries

Speculative graph exploration via hyperbolic diffusion with stochastic noise:

  • DreamEngine: BFS exploration from seed node with noise-perturbed energy detection
  • Energy spike and curvature anomaly event detection
  • Pending/Applied/Rejected dream lifecycle with persistent sessions
  • NQL: DREAM FROM, APPLY DREAM, REJECT DREAM, SHOW DREAMS
  • 8 unit tests (store, engine)

nietzsche-narrative — Narrative Engine

Story arc detection and generation from graph evolution:

  • NarrativeEngine: scans nodes, computes energy statistics, detects elite emergence and decay events
  • Configurable time window, elite/decay thresholds
  • JSON and text output formats with auto-generated summaries
  • NQL: NARRATE IN "collection" WINDOW hours FORMAT json|text
  • 4 unit tests

Synesthesia (in nietzsche-sensory)

Cross-modal projection via hyperbolic parallel transport:

  • translate_modality(): log_map → modal rotation → exp_map on the Poincare ball
  • Preserves hierarchical depth (radius) while changing modality direction
  • Quality loss estimation per modality pair
  • NQL: TRANSLATE $node FROM text TO audio

Eternal Return (in nietzsche-query)

Temporal queries and counterfactual reasoning:

  • AS OF CYCLE N: time-travel queries on named snapshots
  • COUNTERFACTUAL SET ... MATCH ...: what-if queries with ephemeral overlays

Collective Unconscious (in nietzsche-cluster)

Cross-collection archetype sharing via gossip protocol:

  • ArchetypeRegistry: DashMap-based registry with merge_peer_archetypes for gossip
  • NQL: SHOW ARCHETYPES, SHARE ARCHETYPE $node TO "collection"
  • 4 unit tests

nietzsche-agency — Autonomous Agency Engine

Graph-level autonomous intelligence with counterfactual reasoning and active forgetting:

  • AgencyEngine tick loop: runs 10 built-in daemons (Entropy, Gap, Coherence, Ltd, Nezhmetdinov, Shatter, SelfHealing + more) + MetaObserver + 27-step tick protocol
  • Geometric Self (Phase IX): CentroidGuardian (maintains the civilization centroid via Fréchet mean with temporal damping and drift veto to prevent cognitive shocks), MaturityEvaluator (promotes stable embeddings to Axioms using hyperbolic centrality: $C_i = 1 / (1 + d_D(x_i, C_t))$ and analytical angular variance $\text{Var}(\angle) \approx \text{trace}(\Sigma_{\text{tangent}})$ to penalize redundant clusters), and the Two-Tier AxiomRegistry (DashMap L1 + RocksDB L2) for fast $O(1)$ hot-path queries, temporal EraSnapshots, and deep historical persistence.
  • Hyperbolic Health Monitor (Phase X): Pre-emptive structural collapse detector for $K&lt;0$ geometries (> 100k nodes). Computes Radial Density Entropy (RDE) $H = -\sum p_i \ln(p_i)$ to identify pathological mass migration to the boundary (Boundary Crowding). Tracks $mean_r$, $std_r$, $angular_var$ (Angular Variance Collapse to prevent directional crushing), and $centroid_velocity$. Detects Semantic Attractors ("Black Holes" via abnormal radial bin density $p_i &gt; 3\mu$) and healthy structural L-System stratifications.
  • Attention Economy & Hebbian LTP (Phase XII): The ECAN system (attention_economy.rs) introduces a free-market bid/ask model for focus allocation. Paired with hebbian.rs, 'nodes that fire together, wire together', structurally reinforcing active associative pathways via Long-Term Potentiation (LTP).
  • Cognitive Thermodynamics (Phase XIII): Computes Temperature ($T = \sigma_E / \mu_E$), Shannon Entropy, and Helmholtz Free Energy ($F = E - TS$) to classify the graph into Phase States (Solid, Liquid, Gas, Critical). Implements Fourier's Law for heat flow diffusion $q_{ij} = \kappa \cdot (E_i - E_j)$.
  • Semantic Gravity (Phase XIV): Implements gravitational attraction between nodes. Semantic Mass is defined via ECAN energy and degree: $M = E \times \ln(\text{degree} + 1)$. Force follows the inverse-square law on the Riemann/Poincare manifold: $F_{ij} = G \frac{M_i M_j}{d^2}$. Top attractions identify Gravity Wells, generating Pull Intents that physically cluster massive concepts over time.
  • Observability & Navigation (Phase XV): Includes CognitiveDashboard for unified JSON snapshots of all agency subsystems (Health, ECAN, Hebbian, Thermo, Maturity, Gravity, Shatter, Healing, Learning, Compression, Sharding, World Model, Flywheel). ObservationBridge maps cognitive temperature and energy into an ObservationFrame mapping HSV/RGB spectra for direct WebGL 60fps rendering in Perspektive.js. Reduces processing overhead via the DirtySet (Temporal Adaptive Sampling), shifting node update complexity from $O(N)$ to bounded $O(\Delta)$ via lock-free mutation sets.
  • Shatter Protocol (Phase XVI): Super-node splitting daemon. Detects nodes exceeding degree thresholds, builds shatter plans that split a super-node into K avatars (child nodes inheriting subsets of edges), and converts the original into a phantom (ghost) node. Prevents hub monopoly and preserves hyperbolic geometry via centroid-respecting splits.
  • Self-Healing Graph (Phase XIX): Autonomous structural maintenance — detects boundary drift (nodes escaping the Poincaré ball), orphan nodes (zero connectivity), dead edges (pointing to non-existent nodes), exhausted nodes (energy ≈ 0), and ghost node ratio. Emits repair intents that the reactor executes to restore graph health.
  • Graph Learning Engine (Phase XX): Tracks operational patterns across agency ticks — access hotspots, mutation hotspots, sector growth rates. Uses rolling window statistics with exponential decay counters and automatic eviction of low-frequency entries to keep memory bounded. Identifies booming sectors (growth rate > threshold) for proactive resource allocation.
  • Knowledge Compression (Phase XXI): Semantic deduplication and merge engine. 4-phase scan: (1) collect candidate nodes, (2) near-duplicate detection via Poincaré distance $d(a,b) &lt; \varepsilon$, (3) stale cluster identification (low-energy + low-degree groups), (4) redundant path pruning (parallel edges to same target). Produces MergeProposals with confidence scores for reactor execution.
  • Hyperbolic Sharding (Phase XXII): Partition-aware locality analysis respecting Poincaré geometry. Divides the ball into radial bands × angular sectors, assigns nodes by norm (depth) and atan2 (direction), computes per-shard statistics and imbalance ratio. Recommends rebalancing when shard population variance exceeds threshold.
  • World Model Graph (Phase XXIII): Meta-representation of external state — tracks query rates, mutation rates, error rates via rolling statistics. Anomaly detection via z-score (value deviating > sensitivity × σ from mean). Detects quiet periods (rate < 0.3× mean) and busy periods (rate > 2× mean) for adaptive resource scheduling.
  • Cognitive Flywheel (Phase XXIV): Unified feedback loop connecting all subsystems. Assesses per-subsystem health (Healthy/Active/Degraded/Inactive), computes momentum via EMA (exponential moving average with configurable decay factor), tracks healthy streaks, and generates automated recommendations. The flywheel spins when momentum exceeds minimum threshold, creating a self-reinforcing cycle of autonomous intelligence.
  • Hydraulic Flow Engine (Phase XXV): Three-layer biologically-inspired flow system. FlowLedger: per-edge CPU cost accounting (DashMap, lock-free) tracking traversal count, EMA CPU ns, peak pressure. ConductivityTensor: per-edge conductivity: f32 field modifying effective distance (d_eff = d_poincaré / κ), updated by Hebbian LTP, flow reinforcement, and temporal decay (toward baseline 1.0, not 0). MurrayRebalancer: fractal vascular equilibrium during SleepCycle applying Murray's Law (κ_parent³ = Σκ_child³) with damped adjustments and flow-weighted variant. Minimizes Constructal Flow Energy E = Σ(f²/κ). Queryable via NQL 4.0: BEJAN_CONDUCTIVITY, POISEUILLE_FRICTION, MURRAY_RATIO, NAVIER_STOKES_TURBULENCE, ONSAGER_DISSIPATION, ERODE PATH, INJECT ENERGY.
  • EpistemologyDaemon (Phase XXV): Autonomous self-research system inspired by Karpathy's autoresearch. Implements Darwinian selection on Code-as-Data NQL queries: SELECT highest-friction ActionNode (via NodeLedger CPU cost) → PROPOSE mutation (emit EpistemologyCandidate event for external LLM bridge) → EVALUATE in ShadowGraph sandbox with full ΔTGC measurement → VERDICT KEEP (merge) or DISCARD (phantomize). Includes NQL syntax validation gate (Pest parser), content-hash deduplication of rejected mutations, and force_evolution MCP tool for LLM-driven mutation injection. Integrated into the SleepCycle with configurable epistemology_budget (default: 5 evaluations per sleep). Post-sleep MorningReport summarizes overnight discoveries with sleep quality score.
  • ShadowTGC (forgetting/tgc.rs): Full TGC measurement on lightweight ShadowGraph (~130 bytes/node). Computes degree distribution entropy (Shannon H_s), sampled BFS global efficiency (Latora-Marchiori E_g, depth-limited to 5), and mean energy quality. Formula: ShadowTGC = Q × (1 + α·H_s) × (1 + β·E_g) — isomorphic to the main TgcMonitor. Enables counterfactual TGC comparison: shadow_tgc_delta(baseline, mutant) returns the health improvement/degradation of a proposed mutation.
  • NodeLedger (hydraulic/flow_ledger.rs): Per-node CPU cost tracking (parallel to edge-level FlowLedger). DashMap-based lock-free accounting with record(node_id, cpu_ns), EMA smoothing (α=0.1), peak tracking, and friction(node_id) score combining execution count + EMA cost. top_friction_nodes(k) returns the K most expensive nodes — used by EpistemologyDaemon for candidate ranking.
  • Epistemic Evolution (Phase 27): Autonomous knowledge quality improvement via nietzsche-epistemics crate. Evaluates subgraph quality using 5 metrics: hierarchy consistency (depth ordering), coherence (Poincaré distance proportionality), coverage (radial distribution), redundancy (path diversity), and energy balance. Proposes EpistemicMutation intents: new edges for unconnected similar-depth nodes, reclassification for hierarchy violations, energy boosts for undervalued hubs. Configurable via AGENCY_EVOLUTION_27_* env vars. External Python lab (nietzsche-lab/) provides LLM-driven hypothesis generation via Claude API for full autoresearch-style evolution loop.
  • Morning Report (morning_report.rs): Post-sleep discovery summary aggregating SleepReport metrics (Hausdorff delta, semantic drift, commit/rollback) + epistemology results (mutations evaluated/accepted). Computes sleep quality score (0.0–1.0) and generates human-readable narrative. Serializable to JSON for dashboard/API consumption.
  • EntropyDaemon: detects Hausdorff variance spikes across angular regions
  • GapDaemon: identifies knowledge gaps in depth x angle sectors
  • CoherenceDaemon: measures multi-scale diffusion overlap (Chebyshev heat kernel)
  • NezhmetdinovDaemon: Active Forgetting Engine — evaluates node vitality V(n) via sigmoid function, applies Triple Condition (vitality + energy + causal), Ricci curvature veto, and emits ForgettingCondemned events for hard deletion
  • Forgetting Module (15 submodules, 4 Camadas): vitality function, judgment/verdict system, Merkle Tree deletion ledger, Poincare void tracker, TGC calculator, elite drift tracker, anti-gaming monitor, stability monitor, causal immunity, vitality variance health, friction scoring, Zaratustra cycle orchestrator, telemetry writer
  • MetaObserver: produces HealthReports with energy percentiles, fractal status, wake-up triggers
  • CounterfactualEngine: what-if simulations via ShadowGraph (remove/add nodes without mutating real graph)
  • AgencyEventBus: tokio broadcast channel for cross-system event propagation
  • Hegelian Dialectic Engine (dialectic.rs): AGI-2 module — detects contradictions between nodes with opposing polarity, creates Tension nodes at embedding midpoints, synthesizes resolutions during sleep by pulling toward center and creating Semantic synthesis nodes. Full detect -> tension -> synthesize pipeline
  • Code-as-Data (code_as_data.rs): AGI-4 module — NQL queries stored as activatable graph nodes. When a node's energy exceeds its activation_threshold (via heat diffusion / Will-to-Power), the stored query is extracted and can be executed. Includes cooldown, max firings, and exhaustion tracking. Transforms the database into a Turing-complete reactive rule engine
  • Simulate Forgetting binary: 5000-node x 500-cycle standalone simulation with CSV telemetry
  • Motor de Desejo (desire.rs): Transforms knowledge gaps into structured missions. DesireSignal with sector, depth_range, priority, and suggested_query. Priority = 0.4×depth_weight + 0.6×density_weight. Desires above desire_dream_threshold=0.6 auto-trigger TriggerDream intents, creating a closed Desire→Dream→Generation loop
  • Quantum Fidelity (quantum.rs): Bloch sphere state representation for epistemic confidence. Three thresholds: default (0.85), strict (0.90, safety-critical), relaxed (0.65, exploratory). BlochState::fidelity() for quantum state similarity, trace_distance() for confidence bounds
  • 180+ unit tests (event_bus, engine, observer, daemons, shadow, simulator, dialectic, code_as_data, forgetting: 72 tests across all 15 submodules, learning, compression, sharding, world_model, flywheel)

nietzsche-agency — TGC: Topological Generative Capacity

The master health metric for autonomous cognition. Formally implemented in forgetting/tgc.rs with complete mathematical specification:

TGC(t) = intensity × mean_quality × (1 + α·ΔH_s) × (1 + β·ΔE_g)

Where:
  intensity      = nodes_created / active_nodes
  mean_quality   = mean vitality of generated nodes ∈ [0, 1]
  ΔH_s           = structural_entropy(t) - structural_entropy(t-1)   (Shannon degree distribution)
  ΔE_g           = global_efficiency(t) - global_efficiency(t-1)     (Latora-Marchiori, BFS-sampled)
  α              = 2.0  (entropy amplifier)
  β              = 3.0  (efficiency amplifier, β/α = 1.5)
Metric Formula File
Structural Entropy (H_s) -Σ p(k)·ln(p(k)) forgetting/structural_metrics.rs
Global Efficiency (E_g) (1/|S|·(N-1)) Σ 1/d(s,t) forgetting/structural_metrics.rs
Phase Rupture TGC > 1.5 triggers regime alert forgetting/tgc.rs
EMA Smoothing γ=0.2, τ≈4.48 cycles forgetting/tgc.rs
Anti-Gaming 5 Goodhart violations with 50% penalty forgetting/anti_gaming.rs
3 Pathological Attractors Elitist / Minimalist / Stationary forgetting/stability.rs
Telemetry 17-field CSV per cycle forgetting/telemetry.rs

4-Camada Forgetting Architecture (Nezhmetdinov Engine):

  1. Camada 1 — Local Judgment: V(n) = σ(w₁e + w₂H − w₃ξ + w₄π + w₅κ − w₆τ) with Triple Condition + Ricci veto + Causal immunity
  2. Camada 2 — Deletion Ledger: Merkle Tree cryptographic receipts with inclusion proofs
  3. Camada 3 — Generative Metabolism: Void Tracker captures Poincaré coordinates as dream seeds
  4. Camada 4 — Global Health: TGC + Var(V) + Elite Drift + Anti-Gaming (4 vital signs)

Full mathematical specification: docs/articles/NietzscheDB-Topological-Generative-Capacity.md (8 parts, 7 canonical equations).

nietzsche-agency — Quantum-Inspired Cognitive Kernel (Orch-OR Emulation)

Stochastic emulation layer inspired by the Orchestrated Objective Reduction framework (Penrose & Hameroff). Enables the Agency Engine to maintain multiple hypotheses in superposition, accumulate Bayesian evidence, and collapse probabilistically to decisions. Not real quantum computing — mathematical emulation over classical hardware.

  • SemanticQudit: N-dimensional probabilistic state (categorical distribution) with normalized Shannon entropy, Bayesian update via apply_semantic_gravity(), weighted categorical sampling via objective_reduction(), and resuperpose() for post-collapse reuse with prior boost
  • QuantumMicrotubuleManager: Per-node qudit management with lock-free pipeline design — no lock is held during graph traversal or propagation. Atomic stimulate/collapse/propagate phases prevent deadlocks
  • Semantic Entanglement: Collapse of a node propagates Bayesian evidence to graph neighbors with exponential decay ($I = w \cdot \mu_{type} \cdot \gamma^d$), anti-cascade mechanisms (max depth, min influence, visited set, refractory period)
  • CoherenceEvaluator: Composite scoring of hypothetical subgraphs — geometric coherence (Poincaré hierarchy), semantic coherence (cosine similarity with real neighbors), topological coherence (orphan ratio, degree compatibility)
  • Cognitive Superposition Graph (CSG): Beam search over hyperbolic topology — spawns N competing subgraphs ("cognitive realities"), evolves them via coherence scoring, collapses to a winner that merges into the permanent graph. Losers leave probabilistic residue influencing future decisions
  • DeliberationCoordinator: 4 triggers for CSG instantiation — (1) Semantic Ambiguity (KNN top-K delta < threshold), (2) Valence Conflict (contradicting high-energy nodes), (3) Cascade Saturation (propagation hit max depth with high residual entropy), (4) Historical Inconsistency (new claim vs established fact)
  • QuantumEventBus: tokio::sync::broadcast channel emitting QuantumEvent variants (NodeCollapse, EntanglementInfluence, DeliberationStarted/Evolved/Resolved, RemCycleCompleted) via gRPC stream to Go GlobalWorkspace
  • Agency Tick Integration: 3-phase breath — Perception (stimulate) → Unconscious Reaction (propagate cascades) → Conscious Deliberation (evolve active CSGs)

Full specification: docs/architecture/QUANTUM_KERNEL_SPEC.md | Runtime behavior: docs/architecture/COGNITIVE_OS_BEHAVIOR.md

nietzsche-rl — Reinforcement Learning Engine

PPO (Proximal Policy Optimization) for autonomous growth strategy selection:

  • PpoEngine: ONNX-based neural policy inference at runtime
  • 4 growth strategies: Balanced, FavorGrowth, FavorPruning, Consolidate
  • State representation (GrowthState): derived from graph health metrics (energy, Hausdorff, gaps, entropy)
  • Reward function: +1.0 if Hausdorff preserved AND query-speed improves, -1.0 if Hausdorff degrades
  • Training: scripts/models/train_ppo.py (Actor-Critic architecture with LayerNorm + GELU)
  • Export: ONNX model ppo_growth_v1 for runtime inference

nietzsche-neural — Neural Model Registry

ONNX model lifecycle management for all neural components:

  • ModelRegistry with load_model() / get_session() for inference
  • Manages PPO, GNN, and Value Network ONNX sessions
  • Thread-safe model loading with Arc<Mutex>

nietzsche-gnn — Graph Neural Network Engine

GNN inference for topology-aware node evaluation:

  • GnnEngine::predict(): feeds node features + adjacency to ONNX session
  • Zero-data learning: Classical heat kernel (Chebyshev) distills knowledge to GNN
  • Dual loss: MSE (embeddings) + BCE (node importance classification)
  • Integrates with NeuralThresholdDaemon: GNN score > 0.7 triggers node protection
  • Training: scripts/models/train_gnn.py

nietzsche-gnn — Edge Predictor (Link Prediction)

Neural link prediction for graph topology optimization:

  • EdgePredictorNet::predict(): two 128D node embeddings → edge probability [0, 1]
  • predict_batch(): efficient batch inference for multiple candidate pairs
  • Used by L-System to decide where to create new connections (replaces random edge creation)
  • Training: scripts/models/train_edge_predictor.py (binary classification, negative sampling)
  • Architecture: 256D input (node_a ⊕ node_b) → 128 → 64 → sigmoid

nietzsche-sensory — Neural Image & Audio Encoders

CNN-based sensory encoders that replace passthrough with learned features:

  • ImageNeuralEncoder: 64×64 RGB → CNN (3→32→64→128) → FC → 128D → Poincaré ball
    • Contrastive learning (NT-Xent / SimCLR-style)
    • Training: scripts/models/train_image_encoder.py
  • AudioNeuralEncoder: mel spectrogram [1, 64, 32] → CNN → 128D → Poincaré ball
    • Reconstruction-based self-supervised training
    • Training: scripts/models/train_audio_encoder.py

nietzsche-dream — Dream Generator Network

Neural dream synthesis — generates new node embeddings by diffusing from seed:

  • DreamGeneratorNet::dream(seed, creativity): seed 128D + noise 64D → generated 128D
  • Bounded output (Tanh) for safe Poincaré projection
  • MMD (Maximum Mean Discrepancy) regularization keeps dreams on the data manifold
  • Poincaré penalty ensures generated points stay inside the ball
  • Training: scripts/models/train_dream_generator.py

nietzsche-cluster — Cluster Quality Scorer

Neural cluster health evaluation and action recommendation:

  • ClusterScorerNet::score(): centroid 128D + variance 128D + 5 stats → [keep, split, merge]
  • Heuristic-supervised: large/incoherent clusters → split, tiny/dense → merge
  • Training: scripts/models/train_cluster_scorer.py

nietzsche-mcts — Value Network

Neural state evaluator for MCTS tree search (replaces random rollouts):

  • ValueNetworkInference::evaluate(): 64D Krylov state → value score [0, 1]
  • evaluate_batch(): efficient batch evaluation during tree expansion
  • Features: causal connectedness, mean energy, Hausdorff delta, temporal coherence
  • Training: scripts/models/train_value_network.py

nietzsche-dsi — DSI Decoder (Neural Retrieval)

Differentiable Search Index — O(1) neural document retrieval:

  • DsiDecoderNet::decode(): 128D query → 4-level hierarchical VQ codes
  • Each level selects from 1024 codebook entries (argmax over logits)
  • Confidence scores per level for retrieval quality estimation
  • Training: scripts/models/train_dsi_decoder.py

nietzsche-wiederkehr — Anomaly Detector

Autoencoder-based anomaly detection for graph health monitoring:

  • AnomalyDetectorNet::detect(): 64D health state → AnomalyResult
  • Combined score: learned anomaly head + reconstruction error
  • Two-phase training: (1) reconstruction, (2) anomaly classification with injected anomalies
  • 4 anomaly types: spike, collapse, drift, oscillation
  • Training: scripts/models/train_anomaly_detector.py
  • Used by Wiederkehr daemons to flag degenerative graph regions

nietzsche-sleep — Reconsolidation Sleep Cycle

EVA sleeps. During sleep:

  1. Sample high-curvature subgraph via random walk
  2. Snapshot current embeddings (rollback point)
  3. Perturb embeddings in the tangent space (the "dream")
  4. Optimize via RiemannianAdam on the Poincare manifold
  5. Consolidate sensory (Phase 11 — decoder fine-tune, latent replay)
  6. Evaluate epistemology mutations (Phase 25 — Darwinian selection on pending Code-as-Data rewrites, up to epistemology_budget evaluations per cycle)
  7. Measure Hausdorff dimension + semantic drift before and after
  8. Commit if delta(Hausdorff) < threshold AND drift < threshold — identity preserved, reconsolidation accepted
  9. Rollback if identity was destroyed — dream discarded, sensory restored

Extensible via trait hooks: SensoryConsolidator (Phase 11) and EpistemologyConsolidator (Phase 25). Entry points: run(), run_with_sensory(), run_with_epistemology(), run_full().

This prevents catastrophic forgetting while allowing genuine memory reorganization.

Time-travel / Versioning: Named snapshots (SnapshotRegistry) allow creating labeled checkpoints of the entire embedding state, listing all snapshots with timestamps, and restoring any previous state — enabling temporal queries and safe experimentation.

nietzsche-epistemics — Epistemic Quality Metrics

Quantitative measures of knowledge graph quality for the NietzscheLab evolution loop (Phase 27):

  • Hierarchy consistency (hierarchy.rs): fraction of edges respecting Poincaré depth ordering (parent.depth ≤ child.depth)
  • Coherence (coherence.rs): depth coherence (similar-depth association edges) + distance coherence (Poincaré distance proportional to semantic distance)
  • Coverage (coverage.rs): radial distribution uniformity (normalized entropy across depth bins) + energy distribution equity
  • Redundancy (redundancy.rs): path diversity between sampled node pairs (BFS depth-limited to 4 hops, capped at 5 paths)
  • Novelty (novelty.rs): embedding novelty (average minimum Poincaré distance to existing nodes) + structural novelty (2-hop shared neighbor analysis)
  • Unified scorer (scorer.rs): EpistemicScore composite with configurable ScoreWeights, EpistemicDelta for mutation evaluation with is_improvement(threshold) decision function

nietzsche-zaratustra — Autonomous Evolution Engine

Three-phase autonomous cycle inspired by Nietzsche's philosophy:

  1. Will to Power — energy propagation: each node absorbs alpha x mean(neighbour_energy), amplifying high-energy clusters
  2. Eternal Recurrence — temporal echo snapshots: captures periodic state for pattern detection
  3. Ubermensch — elite tier identification: nodes in the top energy fraction are promoted to elite status

Configurable via ZARATUSTRA_INTERVAL_SECS (default 600s). Invocable via gRPC InvokeZaratustra or automatic background scheduler.

nietzsche-algo — Graph Algorithm Library

Eleven built-in graph algorithms, all available via gRPC and HTTP:

Algorithm Type RPC
PageRank Centrality RunPageRank
Louvain Community RunLouvain
Label Propagation Community RunLabelProp
Betweenness Centrality Centrality RunBetweenness
Closeness Centrality Centrality RunCloseness
Degree Centrality Centrality RunDegreeCentrality
WCC (Weakly Connected) Component RunWCC
SCC (Strongly Connected) Component RunSCC
A* Pathfinding Pathfinding RunAStar
Triangle Count Structure RunTriangleCount
Jaccard Similarity Similarity RunJaccardSimilarity

nietzsche-sensory — Sensory Compression Layer

Multi-modal latent vector storage with progressive degradation:

  • Stores latent representations for: text, audio, image, fused modalities
  • Progressive degradation: f32 -> f16 -> int8 -> PQ -> gone
  • Original shape metadata preserved for reconstruction
  • Encoder version tracking for backward compatibility
  • Persisted in RocksDB via graph storage

nietzsche-cluster — Distributed Foundation

Gossip-based cluster discovery and shard routing:

  • ClusterNode — identity, role (primary/replica/coordinator), health
  • ClusterRegistry — gossip-updated peer view
  • ClusterRouter — shard selection
  • Eventual consistency via gossip (no Raft in current phase)
  • Semantic CRDTs (crdt.rs): conflict-free replicated data types for graph merge — add-wins node/edge sets, max-energy wins for concurrent updates, phantom-add-wins (irreversible), Lamport timestamp ordering. GraphDelta struct for gossip transmission with apply_delta() merge
  • Configurable via NIETZSCHE_CLUSTER_ENABLED, NIETZSCHE_CLUSTER_ROLE, NIETZSCHE_CLUSTER_SEEDS

nietzsche-hnsw-gpu — GPU Vector Backend

NVIDIA cuVS CAGRA acceleration for vector search. See GPU Acceleration section.

nietzsche-tpu — TPU Vector Backend

Google TPU acceleration via PJRT C API. See TPU Acceleration section.

nietzsche-cugraph — GPU Graph Traversal

GPU-accelerated graph algorithms via NVIDIA cuGraph:

  • cuGraph BFS/Dijkstra/PageRank on GPU
  • Poincare GPU k-NN with custom CUDA kernel
  • Dynamic FFI loader for libcugraph.so at runtime
  • cudarc + NVRTC for Poincare kernel compilation
  • Feature flag: --features cuda

nietzsche-mcp — Model Context Protocol Server

JSON-RPC 2.0 server for AI assistant integration (Claude, GPT, etc.):

  • 20 tools: graph CRUD, NQL query, KNN search, traversal, graph algorithms, diffusion, stats, force_evolution (LLM mutation bridge for EpistemologyDaemon)
  • force_evolution tool: validates original ActionNode exists, validates mutant NQL syntax via Pest parser, creates mutation_pending node with proper embedding dimensions — enabling any LLM to propose Code-as-Data mutations that the EpistemologyDaemon evaluates during the next sleep cycle
  • Stdin/stdout transport (standard MCP protocol)
  • Parameter validation with typed ParamValue (String, Float, Int, Bool, Vector)
  • 20 unit tests

nietzsche-metrics — Prometheus/OpenTelemetry Metrics

Observability export layer:

  • NODES_INSERTED, EDGES_INSERTED, QUERIES_EXECUTED (CounterVec by collection)
  • QUERY_DURATION_SECONDS, KNN_DURATION_SECONDS, DIFFUSION_DURATION_SECONDS (Histogram)
  • NODE_COUNT, EDGE_COUNT, DAEMON_COUNT, DAEMON_ENERGY_TOTAL (Gauge)
  • Singleton MetricsRegistry with Prometheus text format export (/metrics)
  • 6 unit tests

nietzsche-filtered-knn — Filtered KNN with Roaring Bitmaps

Pre-filtered nearest-neighbor search using Roaring Bitmaps:

  • NodeFilter enum: EnergyRange, NodeType, ContentField, ContentFieldExists, And, Or
  • Energy range filter leverages CF_ENERGY_IDX for efficient range scans
  • JSON dot-path navigation for content field filtering
  • Poincare distance computation for multi-manifold KNN
  • 15 integration tests

nietzsche-named-vectors — Multi-Vector per Node

Multiple named vector embeddings per node:

  • NamedVector { node_id, name, coordinates, metric } with VectorMetric (Poincare, Cosine, Euclidean)
  • Persisted in CF_META with key nvec:{node_id}:{name} (bincode serialization)
  • NamedVectorStore with put/get/list/delete/delete_all operations
  • 8 unit tests

nietzsche-pq — Product Quantization

Magnitude-preserving vector compression (NOT binary quantization — preserves hyperbolic depth):

  • Codebook training via k-means clustering per sub-vector partition
  • PQEncoder with encode/decode: M sub-vectors × K=256 centroids
  • Asymmetric Distance Computation (ADC) via precomputed DistanceTable
  • KEY: test_magnitude_preservation proves PQ preserves ‖x‖ = depth in Poincare ball
  • Configurable: PQConfig { m: 8, k: 256, max_iterations: 25 }
  • 12 unit tests

nietzsche-secondary-idx — Secondary Indexes

Arbitrary JSON field indexing for fast lookups:

  • IndexDef { name, field_path, index_type: String|Float|Int }
  • Persisted in CF_META: definitions at idx_def:{name}, entries at sidx:{name}:{sortable_value}:{node_id}
  • Float encoding: IEEE 754 sign-magnitude to lexicographic order (16 hex chars)
  • SecondaryIndexBuilder with create_index, drop_index, insert_entry, lookup, range_lookup
  • 13 unit tests

nietzsche-kafka — Kafka Connect Sink

Change data capture sink for streaming mutations:

  • GraphMutation enum: InsertNode, DeleteNode, InsertEdge, DeleteEdge, SetEnergy, SetContent
  • KafkaSink with process_message/process_batch (BatchResult with succeeded/failed/errors)
  • SetContent merges JSON fields into existing node content
  • 9 unit tests

nietzsche-swartz — Embedded SQL Engine (GlueSQL on RocksDB)

Full embedded relational SQL engine sharing the same RocksDB instance:

  • SwartzEngine wrapping GlueSQL on the graph's RocksDB column families
  • Full SQL: SELECT, INSERT, UPDATE, DELETE, JOIN, WHERE, GROUP BY, ORDER BY
  • CREATE TABLE / DROP TABLE / ALTER TABLE support
  • gRPC endpoints: SqlQuery, SqlExec, ListSqlTables, DescribeSqlTable
  • Atomic backups included (same RocksDB checkpoint)
  • Zero external dependencies (no separate SQLite process)
  • Named in honor of Aaron Swartz

nietzsche-media — Media/Blob Store (OpenDAL)

Backend-agnostic media storage for files associated with graph nodes:

  • Powered by Apache OpenDAL — supports local filesystem, S3, GCS, Azure, and more
  • MediaMeta { id, node_id, filename, media_type, content_type, size_bytes, created_at }
  • Media types: Image, Audio, Video, Document, Binary
  • MediaStore with put/get/get_meta/delete/list_for_node/exists
  • Flat key structure: {node_id}/{media_id} and {node_id}/{media_id}.meta
  • 8 unit tests

nietzsche-api — Unified gRPC API

Single endpoint for all NietzscheDB capabilities — 71+ RPCs over a single NietzscheDB service, including 6 multi-manifold geometry RPCs (Synthesis, CausalNeighbors, CausalChain, KleinPath, IsOnShortestPath). Every data-plane RPC accepts a collection field; empty -> "default".

service NietzscheDB {
  // ── Collection management ─────────────────────────────────────
  rpc CreateCollection(CreateCollectionRequest)   returns (CreateCollectionResponse);
  rpc DropCollection(DropCollectionRequest)       returns (StatusResponse);
  rpc ListCollections(Empty)                      returns (ListCollectionsResponse);

  // ── Graph CRUD ────────────────────────────────────────────────
  rpc InsertNode(InsertNodeRequest)     returns (NodeResponse);
  rpc GetNode(NodeIdRequest)            returns (NodeResponse);
  rpc DeleteNode(NodeIdRequest)         returns (StatusResponse);
  rpc UpdateEnergy(UpdateEnergyRequest) returns (StatusResponse);
  rpc InsertEdge(InsertEdgeRequest)     returns (EdgeResponse);
  rpc DeleteEdge(EdgeIdRequest)         returns (StatusResponse);
  rpc MergeNode(MergeNodeRequest)       returns (MergeNodeResponse);
  rpc MergeEdge(MergeEdgeRequest)       returns (MergeEdgeResponse);
  rpc IncrementEdgeMeta(IncrementEdgeMetaRequest) returns (IncrementEdgeMetaResponse);

  // ── Batch Operations ──────────────────────────────────────────
  rpc BatchInsertNodes(BatchInsertNodesRequest)   returns (BatchInsertNodesResponse);
  rpc BatchInsertEdges(BatchInsertEdgesRequest)   returns (BatchInsertEdgesResponse);

  // ── Query & Search ────────────────────────────────────────────
  rpc Query(QueryRequest)               returns (QueryResponse);
  rpc KnnSearch(KnnRequest)             returns (KnnResponse);   // supports metadata filters
  rpc FullTextSearch(FullTextSearchRequest) returns (FullTextSearchResponse);
  rpc HybridSearch(HybridSearchRequest) returns (KnnResponse);

  // ── Traversal ─────────────────────────────────────────────────
  rpc Bfs(TraversalRequest)             returns (TraversalResponse);
  rpc Dijkstra(TraversalRequest)        returns (TraversalResponse);
  rpc Diffuse(DiffusionRequest)         returns (DiffusionResponse);

  // ── Graph Algorithms ──────────────────────────────────────────
  rpc RunPageRank(PageRankRequest)             returns (AlgorithmScoreResponse);
  rpc RunLouvain(LouvainRequest)               returns (AlgorithmCommunityResponse);
  rpc RunLabelProp(LabelPropRequest)           returns (AlgorithmCommunityResponse);
  rpc RunBetweenness(BetweennessRequest)       returns (AlgorithmScoreResponse);
  rpc RunCloseness(ClosenessRequest)           returns (AlgorithmScoreResponse);
  rpc RunDegreeCentrality(DegreeCentralityRequest) returns (AlgorithmScoreResponse);
  rpc RunWCC(WccRequest)                       returns (AlgorithmCommunityResponse);
  rpc RunSCC(SccRequest)                       returns (AlgorithmCommunityResponse);
  rpc RunAStar(AStarRequest)                   returns (AStarResponse);
  rpc RunTriangleCount(TriangleCountRequest)   returns (TriangleCountResponse);
  rpc RunJaccardSimilarity(JaccardRequest)     returns (SimilarityResponse);

  // ── Lifecycle ─────────────────────────────────────────────────
  rpc TriggerSleep(SleepRequest)        returns (SleepResponse);
  rpc InvokeZaratustra(ZaratustraRequest) returns (ZaratustraResponse);

  // ── Sensory Compression ───────────────────────────────────────
  rpc InsertSensory(InsertSensoryRequest) returns (StatusResponse);
  rpc GetSensory(NodeIdRequest)           returns (SensoryResponse);
  rpc Reconstruct(ReconstructRequest)     returns (ReconstructResponse);
  rpc DegradeSensory(NodeIdRequest)       returns (StatusResponse);

  // ── Backup / Restore ──────────────────────────────────────────
  rpc CreateBackup(CreateBackupRequest)   returns (BackupResponse);
  rpc ListBackups(Empty)                  returns (ListBackupsResponse);
  rpc RestoreBackup(RestoreBackupRequest) returns (StatusResponse);

  // ── ListStore ────────────────────────────────────────────────
  rpc ListRPush(ListPushRequest)          returns (ListPushResponse);
  rpc ListLRange(ListRangeRequest)        returns (ListRangeResponse);
  rpc ListLen(ListLenRequest)             returns (ListLenResponse);

  // ── Cache (NietzscheDB-compatible) ────────────────────────────────
  rpc CacheSet(CacheSetRequest)           returns (StatusResponse);
  rpc CacheGet(CacheGetRequest)           returns (CacheGetResponse);
  rpc CacheDel(CacheDelRequest)           returns (StatusResponse);
  rpc ReapExpired(ReapExpiredRequest)      returns (ReapExpiredResponse);

  // ── Change Data Capture ───────────────────────────────────────
  rpc SubscribeCDC(CdcRequest)            returns (stream CdcEvent);

  // ── Multi-Manifold Geometry ─────────────────────────────────
  rpc Synthesis(SynthesisRequest)                   returns (SynthesisResponse);
  rpc SynthesisMulti(SynthesisMultiRequest)         returns (SynthesisResponse);
  rpc CausalNeighbors(CausalNeighborsRequest)       returns (CausalNeighborsResponse);
  rpc CausalChain(CausalChainRequest)               returns (CausalChainResponse);
  rpc KleinPath(KleinPathRequest)                   returns (KleinPathResponse);
  rpc IsOnShortestPath(ShortestPathCheckRequest)     returns (ShortestPathCheckResponse);

  // ── Cluster ─────────────────────────────────────────────────
  rpc ExchangeGossip(GossipRequest)       returns (GossipResponse);

  // ── Schema Validation ───────────────────────────────────────
  rpc SetSchema(SetSchemaRequest)         returns (StatusResponse);
  rpc GetSchema(GetSchemaRequest)         returns (GetSchemaResponse);
  rpc ListSchemas(Empty)                  returns (ListSchemasResponse);

  // ── Secondary Indexes ──────────────────────────────────────
  rpc CreateIndex(CreateIndexRequest)     returns (StatusResponse);
  rpc DropIndex(DropIndexRequest)         returns (StatusResponse);
  rpc ListIndexes(ListIndexesRequest)     returns (ListIndexesResponse);

  // ── Admin ─────────────────────────────────────────────────────
  rpc GetStats(Empty)                     returns (StatsResponse);
  rpc HealthCheck(Empty)                  returns (StatusResponse);
}

nietzsche-sdk — Rust Client SDK

Async gRPC client with seed examples (seed_100.rs, seed_1gb.rs).

nietzsche-server — Production Binary

Standalone server binary with env-var-based configuration, background sleep and Zaratustra schedulers, TTL reaper, scheduled backup with auto-pruning, RBAC (Admin/Writer/Reader), cluster gossip, embedded HTTP dashboard, and graceful shutdown.

NIETZSCHE_DATA_DIR=/data/nietzsche \
NIETZSCHE_PORT=50051 \
NIETZSCHE_DASHBOARD_PORT=8080 \
NIETZSCHE_LOG_LEVEL=info \
NIETZSCHE_SLEEP_INTERVAL_SECS=3600 \
ZARATUSTRA_INTERVAL_SECS=600 \
nietzsche-server

HTTP Dashboard & REST API

NietzscheDB ships with an embedded React + Cosmograph 2.1 dashboard, compiled into the binary as a single HTML file. No external web server needed.

Dashboard Tech Stack

Component Version
React 19.2
TypeScript 5.9
Cosmograph 2.1 (GPU graph visualization)
Vite 7.2 + vite-plugin-singlefile
Tailwind CSS 4.1
TanStack React Query 5.90
Radix UI Component primitives
Recharts 3.7

Dashboard Pages

Page Features
Overview Node/edge counts, uptime, version, system config
Collections List, create, inspect collections with dimension/metric
Nodes Browse, insert, delete nodes
Graph Explorer Full Cosmograph 2.1 visualization with timeline, histograms (energy/depth/hausdorff), categorical bars (node_type/edge_type), search, color legend, selection tools
Data Explorer NQL query editor, CRUD forms
Settings Server configuration

REST API Endpoints

Core:

Method Endpoint Description
GET /api/health {status: "ok"}
GET /api/stats Node/edge counts, version, uptime
GET /api/collections List all collections
GET /metrics Prometheus metrics

Data (CRUD):

Method Endpoint Description
GET /api/graph?collection=NAME&limit=N Nodes + edges for visualization
GET /api/node/:id Get single node
POST /api/node Insert node
DELETE /api/node/:id Delete node
POST /api/edge Insert edge
DELETE /api/edge/:id Delete edge
POST /api/batch/nodes Batch insert nodes
POST /api/batch/edges Batch insert edges

Query & Traversal:

Method Endpoint Description
POST /api/query Execute NQL query
POST /api/sleep Trigger sleep cycle
GET /api/search Full-text search

Graph Algorithms:

Method Endpoint Description
GET /api/algo/pagerank PageRank centrality
GET /api/algo/louvain Louvain community detection
GET /api/algo/labelprop Label propagation
GET /api/algo/betweenness Betweenness centrality
GET /api/algo/closeness Closeness centrality
GET /api/algo/degree Degree centrality
GET /api/algo/wcc Weakly connected components
GET /api/algo/scc Strongly connected components
GET /api/algo/triangles Triangle count
GET /api/algo/jaccard Jaccard similarity

Data Management:

Method Endpoint Description
POST /api/backup Create backup
GET /api/backup List backups
GET /api/export/nodes Export all nodes
GET /api/export/edges Export all edges

SDKs

Python

from nietzsche_db import NietzscheClient

db = NietzscheClient("localhost:50051")

# Insert a memory into hyperbolic space (||x|| < 1.0 required)
node_id = db.insert_node(embedding=[0.1, 0.2, 0.3], metadata={"text": "Nietzsche on memory"})

# KNN search
results = db.knn_search(embedding=[0.1, 0.2, 0.3], k=10)

# Run NQL query
results = db.query("MATCH (m:Memory) WHERE m.depth > 0.7 RETURN m LIMIT 5")

# Trigger sleep and reconsolidate
report = db.trigger_sleep(noise=0.02, adam_lr=0.005)
print(f"delta_hausdorff={report.hausdorff_delta:.3f}, committed={report.committed}")

Go (sdk-papa-caolho)

import nietzsche "sdk-papa-caolho"

client, _ := nietzsche.ConnectInsecure("localhost:50052")
defer client.Close()

// Insert node with Poincare embedding
node, _ := client.InsertNode(ctx, nietzsche.InsertNodeOpts{
    Coords:   []float64{0.1, 0.2, 0.3},
    Content:  map[string]string{"text": "first memory"},
    NodeType: "Semantic",
})

// KNN search
results, _ := client.KnnSearch(ctx, []float64{0.1, 0.2, 0.3}, 10, "")

// Graph algorithms
scores, _ := client.RunPageRank(ctx, nietzsche.PageRankOpts{Iterations: 20})

// Trigger sleep
sleep, _ := client.TriggerSleep(ctx, nietzsche.SleepOpts{Noise: 0.02})
fmt.Printf("deltaH=%.3f committed=%v\n", sleep.HausdorffDelta, sleep.Committed)

Go SDK covers all 71+ RPCs: collections, nodes, edges, batch operations, query, search, traversal, algorithms, backup, CDC, merge, sensory, indexes, lifecycle, and multi-manifold operations (Synthesis, CausalNeighbors, CausalChain, KleinPath, IsOnShortestPath).

TypeScript & C++

Located in sdks/ts/ and sdks/cpp/.


Development Roadmap

PHASE 0   Foundation & environment          ✅ COMPLETE
PHASE 1   Node and edge model               ✅ COMPLETE
PHASE 2   Graph storage engine              ✅ COMPLETE
PHASE 3   Traversal engine                  ✅ COMPLETE
PHASE 4   NQL query language                ✅ COMPLETE
PHASE 5   L-System engine                   ✅ COMPLETE
PHASE 6   Fractal diffusion / Pregel        ✅ COMPLETE
PHASE 7   ACID transactions on graph        ✅ COMPLETE
PHASE 8   Reconsolidation (sleep cycle)     ✅ COMPLETE
PHASE 9   Public API + SDKs                 ✅ COMPLETE
PHASE 10  Benchmarks, hardening, production ✅ COMPLETE
PHASE 11  Sensory compression layer         ✅ COMPLETE
PHASE Z   Zaratustra evolution engine       ✅ COMPLETE
PHASE A+B Unified gRPC API (71+ RPCs)       ✅ COMPLETE
PHASE D   Merge semantics (upsert)          ✅ COMPLETE
PHASE G   Cluster foundation (gossip)       ✅ COMPLETE
PHASE GPU GPU acceleration (cuVS CAGRA)     ✅ COMPLETE
PHASE TPU TPU acceleration (PJRT)           ✅ COMPLETE

── Production Hardening Roadmap ─────────────────────────────────
P0.1  TTL Reaper (background expiry)       ✅ COMPLETE
P0.2  RBAC (Admin/Writer/Reader roles)     ✅ COMPLETE
P0.3  Backup Hardening (scheduled+prune)   ✅ COMPLETE
P1.4  NQL CREATE / SET / DELETE            ✅ COMPLETE
P1.5  Metadata Secondary Indexes           ✅ COMPLETE
P1.6  Cluster Gossip Wiring                ✅ COMPLETE
P2.7  Encryption at-rest (AES-256-CTR)     ✅ COMPLETE
P2.8  Multi-hop Path NQL (BoundedBFS)      ✅ COMPLETE
P2.9  ListStore (RPUSH/LRANGE/LLEN)        ✅ COMPLETE
P3.10 Query Cost Estimator (EXPLAIN)       ✅ COMPLETE
P3.11 Hybrid BM25+ANN (RRF fusion)         ✅ COMPLETE
P3.12 Schema Validation (per-NodeType)     ✅ COMPLETE

── Consolidation Sprint (2026-02-21) ──────────────────────
C0.1  Bug fixes (5 real bugs)              ✅ COMPLETE
C0.2  Test coverage (+389 new tests)       ✅ COMPLETE
       Sprint 1: +166 (algo, zaratustra, gpu, graph, query, sparse, autotuner, snapshot)
       Sprint 2: +127 (tpu: 28, cugraph: 41, sdk: 28, wasm: 30)
       Sprint 3: +96  (embed: 49, cli: 47) — 100% module coverage
C1.1  NQL Time Functions (NOW/INTERVAL)    ✅ COMPLETE
C1.2  ListStore list_del method            ✅ COMPLETE
C2.1  SparseVector type                    ✅ COMPLETE
C2.2  HNSW Auto-tuner (ef_search)          ✅ COMPLETE
C2.3  Named Snapshots (time-travel)        ✅ COMPLETE

── Expansion Sprint (2026-02-21) ──────────────────────
E0.1  MCP Server (AI assistant tools)      ✅ COMPLETE  (20 tools, 20 tests)
E0.2  Prometheus/OTel metrics export       ✅ COMPLETE  (12 metrics, 6 tests)
E0.3  Filtered KNN + Roaring Bitmaps       ✅ COMPLETE  (5 filter types, 15 tests)
E0.4  Named Vectors (multi-vector/node)    ✅ COMPLETE  (3 metrics, 8 tests)
E0.5  Product Quantization (PQ)            ✅ COMPLETE  (magnitude-preserving, 12 tests)
E0.6  Secondary Indexes (arbitrary field)  ✅ COMPLETE  (3 index types, 13 tests)
E0.7  Kafka Connect Sink (CDC)             ✅ COMPLETE  (6 mutation types, 9 tests)
E0.8  Table Store (SQLite)                 ✅ COMPLETE  (7 column types, 15 tests)
E0.9  Media/Blob Store (OpenDAL)           ✅ COMPLETE  (5 media types, 8 tests)
E1.0  Go SDK batch RPCs                    ✅ COMPLETE  (42/42 RPCs)

── NQL 4.2 "Beyond the Database" (2026-03-13) ──────
NQL-30 HAVING clause (post-aggregation)   ✅ COMPLETE  (filter on grouped results after GROUP BY)
NQL-31 INTERSECT / EXCEPT set algebra     ✅ COMPLETE  (HashSet intersection/difference by node ID)
NQL-32 CALL stored procedures             ✅ COMPLETE  (CALL name(args) YIELD fields)
NQL-33 EXPLAIN ANALYZE runtime profiling  ✅ COMPLETE  (actual execution time + gas + row count)
NQL-34 CREATE/DROP/SHOW TYPE              ✅ COMPLETE  (user-defined schemas with nullable/default)
NQL-35 JSON path access (-> / ->>)        ✅ COMPLETE  (expr->key returns JSON, ->> returns text)
NQL-36 ANY/ALL quantifiers                ✅ COMPLETE  (existential/universal over arrays)
NQL-37 FETCH HTTP client                  ✅ COMPLETE  (GET/POST with HEADERS, INTO, UNWIND)
NQL-38 STREAM real-time events            ✅ COMPLETE  (MATCH pattern WITH THROTTLE interval)
NQL-39 REGISTER/DROP/SHOW FUNCTION        ✅ COMPLETE  (UDFs in NQL or external languages)
NQL-40 ASK ... ABOUT LLM integration     ✅ COMPLETE  (query AI models with graph CONTEXT)
NQL-41 SCHEDULE cron automation           ✅ COMPLETE  (EVERY interval, DROP/SHOW SCHEDULES)
NQL-42 IMPORT external data               ✅ COMPLETE  (CSV/JSON/Parquet INTO collection)

── Gemini Embedding 2 Integration (2026-03-13) ──
GE-1  GeminiEmbedder Python SDK             ✅ COMPLETE  (text/image/audio/video/multimodal → Poincaré)
GE-2  Matryoshka dim support (128–3072)     ✅ COMPLETE  (auto L2-normalize sub-3072D)
GE-3  exp_map_zero client-side projection   ✅ COMPLETE  (pure Python, matches Rust nietzsche-hyp-ops)
GE-4  precomputed_poincare proto field      ✅ COMPLETE  (skip server-side exp_map_zero)
GE-5  embedding_model provenance tracking   ✅ COMPLETE  (model ID stored in modality_meta)
GE-6  Task-type aware asymmetric retrieval  ✅ COMPLETE  (embed_query vs embed_document)

── NQL 3.0 Sprint (2026-03-01) ─────────────────────
NQL-8  OPTIONAL MATCH (left-outer-join)    ✅ COMPLETE
NQL-9  UNION / UNION ALL                   ✅ COMPLETE
NQL-10 CASE WHEN expression               ✅ COMPLETE
NQL-11 IS NULL / IS NOT NULL               ✅ COMPLETE
NQL-12 Regex matching (=~)                 ✅ COMPLETE
NQL-13 EXISTS subquery                     ✅ COMPLETE
NQL-14 UNWIND                              ✅ COMPLETE
NQL-15 SHORTEST_PATH                       ✅ COMPLETE
NQL-16 MATCH ELITES                        ✅ COMPLETE
NQL-17 MEASURE TENSION / MEASURE TGC       ✅ COMPLETE
NQL-18 FIND NEAREST                        ✅ COMPLETE
NQL-19 COLLECT aggregation                 ✅ COMPLETE
NQL-20 30+ built-in functions              ✅ COMPLETE  (string: 11, math: 10, cast: 4, null: 1)
NQL-21 5 physicist cognitive functions      ✅ COMPLETE  (Boltzmann, Helmholtz, Lyapunov, Prigogine, Erdős)
NQL-22 Null-safe comparison semantics      ✅ COMPLETE  (SQL-like NULL propagation)

── EVA Compatibility Sprint (2026-02-21) ──────────
A.1   Multi-Metric HNSW fix + DotProduct   ✅ COMPLETE  (Euclidean bug fixed, DotProduct added)
A.2   EmbeddedVectorStore as default       ✅ COMPLETE  (Mock → Embedded, real HNSW by default)
B.2   KNN metadata filter push-down        ✅ COMPLETE  (MetadataFilter → RoaringBitmap pre-filter)
D.1   MergeEdge ON MATCH + edge metadata   ✅ COMPLETE  (update_edge_metadata + WAL entries)
D.2   IncrementEdgeMeta RPC               ✅ COMPLETE  (atomic counter increment on edges)
E.1   Persistent secondary index registry  ✅ COMPLETE  (create/drop/list + backfill + startup load)
E.2   NQL executor index integration       ✅ COMPLETE  (auto O(log N) scan for indexed WHERE)
E.3   Index management gRPC RPCs           ✅ COMPLETE  (CreateIndex/DropIndex/ListIndexes)

── NQL & EVA Compatibility (2026-02-21) ──────────
NQL-1 MERGE statement (ON CREATE/ON MATCH)  ✅ COMPLETE  (node + edge MERGE with upsert)
NQL-2 Multi-hop typed path (*1..4)          ✅ COMPLETE  (BFS with depth + label filter)
NQL-3 SET with arithmetic expressions       ✅ COMPLETE  (n.count = n.count + 1, per-node eval)
NQL-4 CREATE with TTL support               ✅ COMPLETE  (ttl property → expires_at auto-compute)
NQL-5 DETACH DELETE                         ✅ COMPLETE  (node + all incident edges)
NQL-6 Edge property access in WHERE/RETURN  ✅ COMPLETE  (edge alias -[r:TYPE]-> with r.field)
NQL-7 ORDER BY on edge properties           ✅ COMPLETE  (r.weight, r.created_at, etc.)
Ph.C  NietzscheDB-compatible cache RPCs           ✅ COMPLETE  (CacheSet/Get/Del + ReapExpired)
Ph.F  Sensory RPCs (fully connected)        ✅ COMPLETE  (insert/get/reconstruct/degrade)
Ph.G  Per-collection RwLock concurrency     ✅ COMPLETE  (DashMap + tokio::sync::RwLock)

── AGI & Advanced Features Sprint (2026-02-22) ──────────
AGI-1 EnergyCircuitBreaker (anti-tumor)    ✅ COMPLETE  (depth caps, BFS tumor detection, dampening)
AGI-2 Hegelian Dialectic Engine            ✅ COMPLETE  (contradiction→tension→synthesis pipeline)
AGI-3 Semantic CRDTs (cluster merge)       ✅ COMPLETE  (add-wins, max-energy, phantom-add-wins)
AGI-4 Code-as-Data (NQL-as-node)           ✅ COMPLETE  (activatable queries, cooldown, exhaustion)
AGI-5 Schrödinger Edges                    ✅ COMPLETE  (probabilistic collapse, decay, reinforce)
AGI-6 Valence/Arousal (emotional vectors)  ✅ COMPLETE  (diffusion modulation, Laplacian weighting)

── Multi-Manifold Sprint (2026-02-22) ──────────
MM-1  Klein model (pathfinding)            ✅ COMPLETE  (to_klein, to_poincare, colinearity O(1), 10 tests)
MM-2  Riemann sphere (synthesis)           ✅ COMPLETE  (synthesis, synthesis_multi, Fréchet mean, 10 tests)
MM-3  Minkowski spacetime (causality)      ✅ COMPLETE  (ds², classify, light_cone_filter, 8 tests)
MM-4  Manifold normalization layer         ✅ COMPLETE  (health checks, safe roundtrips, 10x error < 1e-4)
MM-5  Edge causality metadata              ✅ COMPLETE  (CausalType enum, minkowski_interval on Edge)
MM-6  6 new gRPC RPCs                      ✅ COMPLETE  (Synthesis, SynthesisMulti, CausalNeighbors, CausalChain, KleinPath, IsOnShortestPath)
MM-7  Go SDK manifold methods              ✅ COMPLETE  (6 methods + types + proto sync)

── Neural & RL Stack (2026-02-24) ──────────
NRL-1  PPO Engine (ONNX inference)          ✅ COMPLETE  (4 strategies, GrowthState, GrowthAction)
NRL-2  Neural Model Registry                ✅ COMPLETE  (load/get ONNX sessions, thread-safe)
NRL-3  GNN Engine (node importance)         ✅ COMPLETE  (predict, dual loss, zero-data distillation)
NRL-4  Training scripts (Python)            ✅ COMPLETE  (train_ppo.py, train_gnn.py, train_value_network.py)
NRL-5  Edge Predictor (link prediction)     ✅ COMPLETE  (256D→sigmoid, batch predict, L-System integration)
NRL-6  Image Neural Encoder (CNN)           ✅ COMPLETE  (64x64 RGB→128D, contrastive, Poincaré projection)
NRL-7  Audio Neural Encoder (Conv)          ✅ COMPLETE  (mel-spec→128D, reconstruction, Poincaré projection)
NRL-8  Dream Generator Network              ✅ COMPLETE  (seed+noise→128D, MMD+Poincaré penalty, Tanh bound)
NRL-9  Cluster Quality Scorer               ✅ COMPLETE  (centroid+var+stats→keep/split/merge, heuristic labels)
NRL-10 MCTS Value Network training          ✅ COMPLETE  (64D state→value [0,1], MSE, graph health features)
NRL-11 DSI Decoder (neural retrieval)       ✅ COMPLETE  (128D query→4-level VQ codes, O(1) lookup)
NRL-12 Anomaly Detector (autoencoder)       ✅ COMPLETE  (2-phase: reconstruction + anomaly classification)

── Nezhmetdinov Forgetting Engine (2026-02-24) ──────────
NZH-1  Vitality sigmoid function           ✅ COMPLETE  (V(n) = σ(w₁e+w₂H-w₃ξ+w₄π+w₅κ-w₆τ), batch, 8 tests)
NZH-2  Judgment/Verdict system             ✅ COMPLETE  (5 verdicts, MikhailThallReport, 6 tests)
NZH-3  HardBounds + NezhmetdinovConfig     ✅ COMPLETE  (immutable bounds, from_env, enforce, 7 tests)
NZH-4  Ricci curvature shield              ✅ COMPLETE  (degree-variance proxy, quick_veto, simulate, 5 tests)
NZH-5  Causal immunity (Minkowski)         ✅ COMPLETE  (timelike/lightlike/spacelike classify, 4 tests)
NZH-6  Deletion ledger (Merkle Tree)       ✅ COMPLETE  (receipts, root, inclusion proofs, 6 tests)
NZH-7  Void tracker (Poincaré seeds)       ✅ COMPLETE  (coordinate capture, plausibility, capacity, 5 tests)
NZH-8  TGC calculator                      ✅ COMPLETE  (EMA smoothing, declining detection, 5 tests)
NZH-9  Elite drift tracker                 ✅ COMPLETE  (centroid tracking, drift threshold, 4 tests)
NZH-10 Anti-gaming (Goodhart)              ✅ COMPLETE  (5 violation types, 50% penalty, 5 tests)
NZH-11 Stability monitor                   ✅ COMPLETE  (3 collapses: elitist/minimalist/stationary, 5 tests)
NZH-12 Vitality variance health            ✅ COMPLETE  (4 classes: diverse/mono/chaotic/exhausted, 4 tests)
NZH-13 Friction calculator                 ✅ COMPLETE  (per-cycle friction scoring, 3 tests)
NZH-14 Zaratustra cycle orchestrator       ✅ COMPLETE  (master 4-Camada orchestration, 5 tests)
NZH-15 Telemetry writer (CSV)              ✅ COMPLETE  (format_cycle_summary, CycleTelemetry, 3 tests)
NZH-16 NezhmetdinovDaemon                  ✅ COMPLETE  (AgencyDaemon trait, full pipeline, 3 tests)
NZH-17 Reactor integration                 ✅ COMPLETE  (HardDelete + RecordDeletion intents)
NZH-18 Simulation binary                   ✅ COMPLETE  (5000 nodes × 500 cycles, CSV output)
       Total: 18 new files, 15 submodules, 72 forgetting tests, 155 total agency tests

── Epistemology Sprint (2026-03-10) ─────────────────
EP-0   force_evolution MCP tool              ✅ COMPLETE  (LLM mutation bridge, NQL validation, 20 MCP tools total)
EP-1   NQL syntax validator in daemon        ✅ COMPLETE  (Pest parser gate pre-simulation)
EP-2   ShadowTGC (full TGC on ShadowGraph)   ✅ COMPLETE  (degree entropy + BFS efficiency, shadow_tgc_delta)
EP-3   SleepCycle epistemology integration   ✅ COMPLETE  (EpistemologyConsolidator trait, budget config, run_full)
EP-4   Morning Report generation             ✅ COMPLETE  (sleep quality score, discovery summaries, JSON)
EP-5   NodeLedger (per-action CPU tracking)  ✅ COMPLETE  (DashMap, EMA, friction ranking, top_friction_nodes)
EP-6   EpistemologyDaemon                    ✅ COMPLETE  (2-phase tick: candidate selection + mutation evaluation)
EP-7   Reactor integration                   ✅ COMPLETE  (EpistemologyMerge + Phantomize intents)
       Total: 6 new files, 2 new traits, 20+ epistemology tests

Benchmarks

Run all benchmarks:

cargo bench --workspace

Individual suites:

Suite Command
Graph engine cargo bench -p nietzsche-graph
Riemannian ops cargo bench -p nietzsche-sleep
Chebyshev / diffusion cargo bench -p nietzsche-pregel
Hyperbolic math cargo bench -p nietzsche-hyp-ops
Distance metrics cargo bench -p nietzsche-core

Representative results (ring graph, Apple M2)

Benchmark N Time
graph/insert_node 1 ~18 us
graph/insert_node_batch 100 ~1.4 ms
graph/scan_nodes 500 ~3.8 ms
graph/bfs chain-50 ~52 us
graph/dijkstra chain-50 ~81 us
riemannian/exp_map dim=256 ~420 ns
riemannian/adam_10_steps dim=64 ~6.2 us
chebyshev/apply_heat_kernel ring-40 ~210 us
chebyshev/laplacian_build ring-50 ~390 us

Hyperbolic Math Benchmarks (nietzsche-hyp-ops)

Benchmark Dimension Operations
exp_map_zero 64d, 256d Euclidean → Poincaré projection
log_map_zero 64d Poincaré → tangent space
mobius_add 64d Gyrovector addition
poincare_distance 64d Hyperbolic geodesic distance
gyromidpoint 3×256d Fréchet mean (multimodal fusion)

Cognitive Simulation: Forgetting Engine

Standalone binary simulate_forgetting runs a full 4-Camada Zaratustra cycle at scale:

Parameter Value
Nodes 10,000 (1,000 signal + 9,000 noise)
Edges ~50,000 undirected
Cycles 100+ accelerated
Metrics per cycle TGC (raw + EMA), H_s, E_g, Var(V), elite drift, deletion rate
Output CSV telemetry with all 4 vital signs
Validation Zero false positives (no signal nodes killed), noise converges to zero

Three telemetry profiles: D_foam (void-born orphans), E_anchored (elite-parented), F_dialectical (elite + entropy polarization).

Test Coverage

Module Tests Key areas
nietzsche-agency 155 Event bus, 8 daemons, observer, reactor, desire, identity, counterfactual, dialectic, code-as-data
nietzsche-agency/forgetting 72 Vitality, judgment, bounds, Ricci, causal immunity, ledger, TGC, elite drift, anti-gaming, stability, variance, friction, Zaratustra cycle
nietzsche-hyp-ops 40+ All 4 geometries, manifold roundtrips, synthesis, Minkowski causality
nietzsche-query 155+ NQL parser, executor, all statement types (NQL 4.2: HAVING, INTERSECT/EXCEPT, CALL, FETCH, STREAM, ASK, SCHEDULE, IMPORT, JSON path, type system, UDFs)
nietzsche-graph 50+ Storage, traversal, merge, fulltext, schrodinger
Total workspace 800+ All 41 crates with unit + integration tests

Cross-Database Benchmark Suite (benchmarks/)

Modular plugin-based runner comparing NietzscheDB against Milvus, NietzscheDB, and ChromaDB:

  • Throughput (Insert/Search QPS), Latency (P50/P95/P99)
  • Recall@10, MRR@10, NDCG@10
  • System Recall@10 (vs exact brute-force)
  • Concurrency profile (C1/C10/C30)

Production Deployment

Docker Compose (recommended)

# docker-compose.yaml
services:
  nietzsche:
    build: .
    ports:
      - "50052:50051"   # gRPC
      - "8080:8080"     # HTTP dashboard
    environment:
      NIETZSCHE_DATA_DIR:            /data/nietzsche
      NIETZSCHE_PORT:                "50051"
      NIETZSCHE_DASHBOARD_PORT:      "8080"
      NIETZSCHE_SLEEP_INTERVAL_SECS: "300"
      ZARATUSTRA_INTERVAL_SECS:      "600"
    volumes:
      - nietzsche_data:/data/nietzsche

  nietzsche:
    build:
      context: .
      dockerfile: deploy/docker/Dockerfile
    ports:
      - "50051:50051"
      - "50050:50050"
    environment:
      NIETZSCHE_ADDR: http://nietzsche:50052
    depends_on:
      - nietzsche
    volumes:
      - nietzsche_data:/data/nietzsche

  prometheus:
    image: prom/prometheus
    ports:
      - "9090:9090"

  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"

Docker (standalone)

# Build
docker build -t nietzsche-db:latest .

# Run
docker run -d \
  -p 50051:50051 \
  -p 8080:8080 \
  -v /data/nietzsche:/data/nietzsche \
  -e NIETZSCHE_LOG_LEVEL=info \
  -e NIETZSCHE_SLEEP_INTERVAL_SECS=300 \
  -e NIETZSCHE_DASHBOARD_PORT=8080 \
  --name nietzsche-db \
  nietzsche-db:latest

Environment Variables

Variable Default Description
NIETZSCHE_DATA_DIR /data/nietzsche RocksDB + WAL + collections root
NIETZSCHE_PORT 50051 gRPC listen port
NIETZSCHE_DASHBOARD_PORT 8080 HTTP dashboard port (0 = disabled)
NIETZSCHE_LOG_LEVEL info Tracing filter (trace, debug, info, warn, error)
NIETZSCHE_SLEEP_INTERVAL_SECS 0 Sleep cycle interval in seconds (0 = disabled)
NIETZSCHE_SLEEP_NOISE 0.02 Tangent-space perturbation magnitude
NIETZSCHE_SLEEP_ADAM_STEPS 10 RiemannianAdam steps per sleep cycle
NIETZSCHE_HAUSDORFF_THRESHOLD 0.15 Max delta-hausdorff before rollback
NIETZSCHE_MAX_CONNECTIONS 1024 Maximum concurrent gRPC connections
NIETZSCHE_VECTOR_BACKEND embedded embedded (HNSW), gpu, tpu, or empty (mock)
NIETZSCHE_API_KEY Admin auth token for gRPC (backward compat)
NIETZSCHE_API_KEY_ADMIN Admin role API key
NIETZSCHE_API_KEY_WRITER Writer role API key (read + mutate)
NIETZSCHE_API_KEY_READER Reader role API key (read only)
NIETZSCHE_ENCRYPTION_KEY Base64-encoded 32-byte AES master key (empty = disabled)
NIETZSCHE_TTL_REAPER_INTERVAL_SECS 60 TTL reaper scan interval (0 = disabled)
NIETZSCHE_BACKUP_INTERVAL_SECS 0 Automatic backup interval (0 = disabled)
NIETZSCHE_BACKUP_RETENTION_COUNT 5 Max backups to keep (older ones pruned)
NIETZSCHE_INDEXED_FIELDS CSV of metadata fields to index (e.g. created_at,category)
ZARATUSTRA_INTERVAL_SECS 600 Zaratustra cycle interval (0 = disabled)
NIETZSCHE_CLUSTER_ENABLED false Enable cluster mode
NIETZSCHE_CLUSTER_NODE_NAME nietzsche-0 Human-readable node name
NIETZSCHE_CLUSTER_ROLE primary primary, replica, or coordinator
NIETZSCHE_CLUSTER_SEEDS Comma-separated seed peer addresses
PJRT_PLUGIN_PATH Path to libtpu.so for TPU backend

Health Check

# gRPC health (requires grpcurl)
grpcurl -plaintext localhost:50051 nietzsche.NietzscheDB/HealthCheck

# HTTP dashboard health
curl http://localhost:8080/api/health

# List all collections
curl http://localhost:8080/api/collections

# Graph data for visualization
curl "http://localhost:8080/api/graph?collection=eva_core&limit=500"

CI / CD

.github/workflows/ci.yml — runs on every PR:

Job What it does
lint cargo fmt --check + cargo clippy -D warnings
test cargo test --workspace --all-features (requires protoc + libclang)
bench-dry-run cargo bench --no-run --workspace (compile check)
docker docker build (validates Dockerfile; no push on PRs)

.github/workflows/deploy-gcp.yml — runs on push to main:

Job What it does
build-and-push Builds Docker image, pushes to GCP Artifact Registry via WIF
deploy SSH into GCP VM via OS Login, runs docker compose up -d
Health check Verifies GET /api/health returns 200

NietzscheLab — Autonomous Knowledge Evolution

NietzscheLab implements an autoresearch-style loop (inspired by Karpathy's autoresearch) for autonomous epistemic evolution:

Hypothesis Generator (LLM) → Mutation → Epistemic Scorer → Accept/Reject → Journal

Quick Start

cd nietzsche-lab
pip install -r requirements.txt

# Dry run (no mutations, just generate hypotheses)
python lab_runner.py --collection tech_galaxies --dry-run --max-experiments 5

# Random baseline (no LLM needed)
python lab_runner.py --collection lab_test --random-only --max-experiments 20

# Full LLM-driven evolution (requires ANTHROPIC_API_KEY)
python lab_runner.py --collection lab_test --max-experiments 50

Architecture

Component File Role
Lab Runner lab_runner.py Main loop: hypothesize → mutate → measure → select
Hypothesis Generator hypothesis_generator.py LLM-driven or random hypothesis creation
Consistency Scorer consistency_scorer.py Before/after metrics (hierarchy, coherence, energy)
Experiment Journal experiment_journal.py JSONL log of all experiments with full metrics
gRPC Client grpc_client.py HTTP/gRPC wrapper for NietzscheDB

Rust Integration (Phase 27)

The Agency Engine runs epistemic evolution autonomously every 40 ticks:

AGENCY_EVOLUTION_27_ENABLED=true
AGENCY_EVOLUTION_27_INTERVAL=40
AGENCY_EVOLUTION_27_MAX_EVAL=500
AGENCY_EVOLUTION_27_QUALITY_FLOOR=0.4
AGENCY_EVOLUTION_27_MAX_PROPOSALS=5

The nietzsche-epistemics crate provides 5 metrics: hierarchy consistency, coherence, coverage, redundancy, and novelty — computed directly on the Poincaré ball geometry.


Installation Guide

NietzscheDB can be installed as a system service on Linux or run locally on Windows for development.

System Requirements

Component Minimum Recommended
OS Ubuntu 22.04 / Debian 12 Ubuntu 24.04 LTS
CPU 4 cores 8+ cores
RAM 8 GB 32 GB
Disk 20 GB SSD 100 GB NVMe
GPU NVIDIA T4 / L4 / A100 (CUDA 12.x)
Rust nightly (required) latest nightly

Linux — Automated Install (recommended)

The installer creates a nietzsche system user, sets up FHS-compliant directories, installs the binary and systemd service.

# Clone the repository
git clone https://github.com/JoseRFJuniorLLMs/NietzscheDB.git
cd NietzscheDB

# Option A: Build + install in one step
sudo ./dist/install.sh

# Option B: Install a pre-built binary
sudo ./dist/install.sh --binary /path/to/nietzsche-server

What gets installed

/usr/local/bin/nietzsche-server          # Server binary
/etc/nietzschedb/nietzschedb.env         # Configuration (preserved on upgrades)
/var/lib/nietzschedb/data/               # RocksDB collections & WAL
/var/lib/nietzschedb/models/             # ONNX neural models
/var/log/nietzschedb/                    # Logs (via journald)
/etc/systemd/system/nietzschedb.service  # Systemd unit

Managing the service

sudo systemctl start nietzschedb      # Start
sudo systemctl stop nietzschedb       # Stop
sudo systemctl restart nietzschedb    # Restart
sudo systemctl status nietzschedb     # Status
journalctl -u nietzschedb -f          # Live logs

Configuration

Edit /etc/nietzschedb/nietzschedb.env and restart the service. All variables are optional — defaults are production-safe. Key settings:

NIETZSCHE_DATA_DIR=/var/lib/nietzschedb/data   # Storage root
NIETZSCHE_PORT=50051                           # gRPC port
NIETZSCHE_DASHBOARD_PORT=8080                  # HTTP dashboard (0 = off)
NIETZSCHE_LOG_LEVEL=info                       # trace|debug|info|warn|error
NIETZSCHE_VECTOR_BACKEND=embedded              # embedded|gpu|tpu
NIETZSCHE_SLEEP_INTERVAL_SECS=0                # Sleep cycle (0 = off)
ZARATUSTRA_INTERVAL_SECS=0                     # Cognitive cycle (0 = off)

See the full variable reference in the Environment Variables table above.

Uninstall

sudo ./dist/install.sh --uninstall
# Data and config are preserved. To remove everything:
sudo rm -rf /etc/nietzschedb /var/lib/nietzschedb /var/log/nietzschedb

Linux — Debian Package (.deb)

For Debian/Ubuntu systems, generate a .deb package:

# Install cargo-deb (one-time)
cargo install cargo-deb

# Build the package
cargo deb -p nietzsche-server

# Install
sudo dpkg -i target/debian/nietzsche-server_*.deb

# Enable and start
sudo systemctl enable --now nietzschedb

The .deb package includes the binary, default config, systemd service, and a post-install script that creates the system user and directories automatically.

Linux — GPU Build (NVIDIA cuVS)

For GPU-accelerated vector search, the build host needs CUDA 12.x and cuVS 24.6:

# Prerequisites
apt-get install -y clang libclang-dev

# cuVS via conda (recommended)
conda create -n cuvs -c rapidsai -c nvidia cuvs=24.6 cuda-version=12.4
conda activate cuvs

# Export build paths (REQUIRED — build fails without these)
export CUVS_ROOT=$CONDA_PREFIX
export CMAKE_PREFIX_PATH=$CUVS_ROOT
export CPATH=$CUVS_ROOT/include
export LD_LIBRARY_PATH=$CUVS_ROOT/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$CUVS_ROOT/lib

# Build with GPU (default feature)
cargo build --release -p nietzsche-server

# Install
sudo ./dist/install.sh --binary target/release/nietzsche-server

Then set NIETZSCHE_VECTOR_BACKEND=gpu in /etc/nietzschedb/nietzschedb.env.

Windows — Development Setup

Windows is supported for development only (individual crate checks and tests). The full server binary requires CUDA/cuVS and must be compiled on Linux.

Requirements

Component Version Notes
Rust nightly rustup default nightly
Visual Studio Build Tools 2022 C++ workload (MSVC, Windows SDK, CMake)
LLVM / Clang 16+ Required by RocksDB (libclang). Set LIBCLANG_PATH
Protobuf Compiler 3.x+ protoc in PATH (for gRPC proto generation)
Git 2.x Git Bash or WSL

Install Rust nightly

# Install rustup (if not present)
winget install Rustlang.Rustup

# Switch to nightly
rustup default nightly
rustup update

Install Build Tools

# Visual Studio Build Tools (C++ workload)
winget install Microsoft.VisualStudio.2022.BuildTools

# LLVM (for RocksDB bindgen)
winget install LLVM.LLVM
# Add to environment:
# LIBCLANG_PATH = C:\Program Files\LLVM\bin

# Protobuf compiler
winget install Google.Protobuf

What works on Windows

# Check individual crates (no GPU needed)
cargo check -p nietzsche-graph
cargo check -p nietzsche-query
cargo check -p nietzsche-agency
cargo check -p nietzsche-hyp-ops
cargo check -p nietzsche-sleep

# Run tests for individual crates
cargo test -p nietzsche-hyp-ops
cargo test -p nietzsche-experiment
cargo test -p nietzsche-query

What does NOT compile on Windows

Crate Reason
nietzsche-server Depends on nietzsche-hnsw-gpu (CUDA/cuVS)
nietzsche-hnsw-gpu Requires CUDA Toolkit 12.x + cuVS SDK
nietzsche-lsystem (cuda feature) Requires CUDA Toolkit
nietzsche-tpu Requires libtpu.so (Linux only)

WSL2 Alternative (full build on Windows)

To build the full server on a Windows machine, use WSL2 with an Ubuntu image:

# Install WSL2 with Ubuntu
wsl --install -d Ubuntu-24.04

# Inside WSL2 (Linux environment)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly -y
sudo apt-get install -y clang libclang-dev protobuf-compiler build-essential

cd /mnt/d/DEV/NietzscheDB
cargo build --release -p nietzsche-server --no-default-features  # CPU-only

Note: GPU passthrough in WSL2 requires NVIDIA GPU + latest Windows drivers + CUDA Toolkit inside WSL. See NVIDIA WSL docs.


GPU Acceleration

NietzscheDB supports GPU-accelerated vector search via NVIDIA cuVS CAGRA and GPU graph traversal via NVIDIA cuGraph.

Vector Search — nietzsche-hnsw-gpu

Insert → CPU staging buffer (Vec<f32>)
               │
               ├── n < 1,000 vectors  → CPU linear scan
               └── n >= 1,000 vectors → CAGRA build on GPU (lazy, on first knn)
                                         └── GPU search → results back to CPU
  • Lazy CAGRA index build: only constructs GPU index when first k-NN query arrives
  • Dirty ratio rebuild: reconstructs when >= 10% of index modified
  • Automatic fallback to CPU if GPU fails

Graph Traversal — nietzsche-cugraph

  • GPU-accelerated BFS, Dijkstra, PageRank via cuGraph FFI
  • Custom CUDA kernel for Poincare distance computation (compiled via NVRTC)
  • Dynamic libcugraph.so loading at runtime

Build (GCP / Linux)

# 1. CUDA Toolkit 12.x + cuVS 24.6
apt-get install -y clang libclang-dev

# 2. Build with GPU support
cargo build --release --features gpu

# 3. Run with GPU backend
NIETZSCHE_VECTOR_BACKEND=gpu ./target/release/nietzsche-server

Docker (GPU)

# Dockerfile.gpu
FROM nvidia/cuda:12.4-devel-ubuntu22.04 AS builder
RUN apt-get update && apt-get install -y clang libclang-dev curl
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
COPY . .
RUN cargo build --release --features gpu

FROM nvidia/cuda:12.4-runtime-ubuntu22.04
COPY --from=builder /target/release/nietzsche-server /usr/local/bin/
EXPOSE 50051 8080
CMD ["nietzsche-server"]
# docker-compose.gpu.yml
services:
  nietzsche-server:
    image: nietzsche-server:gpu
    runtime: nvidia
    environment:
      NIETZSCHE_VECTOR_BACKEND: gpu
      NIETZSCHE_DATA_DIR: /data/nietzsche
    ports:
      - "50051:50051"
      - "8080:8080"
    volumes:
      - nietzsche_data:/data/nietzsche

GCP GPU Instance Recommendation

Instance GPU VRAM Best for
g2-standard-4 L4 24 GB Production — best price/perf
n1-standard-4 + T4 T4 16 GB Budget option
a2-highgpu-1g A100 40 GB Large-scale datasets

Feature Flags

# nietzsche-server/Cargo.toml
[features]
gpu = ["dep:nietzsche-hnsw-gpu"]   # enables GPU injection in main.rs

# nietzsche-hnsw-gpu/Cargo.toml
[features]
cuda = ["dep:cuvs", "dep:ndarray"] # enables actual CUDA calls

TPU Acceleration

NietzscheDB supports Google TPU-accelerated vector search via the PJRT C API, targeting Cloud TPU VMs (v5e, v6e Trillium, v7 Ironwood).

Architecture

Insert → CPU staging buffer (Vec<f32>)
               │
               ├── n < 1,000 vectors  → CPU linear scan
               └── n >= 1,000 vectors → lazy MHLO compile (once)
                                         ├── upload %query  → TPU
                                         ├── upload %matrix → TPU
                                         ├── execute MHLO kernel
                                         └── CPU: L2 norm correction

Hardware Targets

TPU Generation HBM
v5e 5th gen 16 GB/chip
v6e Trillium 32 GB/chip
v7 Ironwood 192 GB/chip

Build (Cloud TPU VM)

PJRT_PLUGIN_PATH=/lib/libtpu.so \
cargo build --release --features tpu

PJRT_PLUGIN_PATH=/lib/libtpu.so \
NIETZSCHE_VECTOR_BACKEND=tpu \
./target/release/nietzsche-server

Feature Flags

# nietzsche-server/Cargo.toml
[features]
tpu = ["dep:nietzsche-tpu", "nietzsche-tpu/tpu"]

# nietzsche-tpu/Cargo.toml
[features]
tpu = ["dep:pjrt"]

GPU vs TPU

Feature GPU (cuVS CAGRA) TPU (PJRT MHLO)
Index type ANN graph (HNSW-like) Exact dot-product batch
Best for Ultra-low latency, single query High throughput, large batch
Memory GPU VRAM (CUDA managed) TPU HBM (192 GB on Ironwood)
Cloud GCP GPU instances GCP Cloud TPU VMs
Feature flag --features gpu --features tpu
Env var NIETZSCHE_VECTOR_BACKEND=gpu NIETZSCHE_VECTOR_BACKEND=tpu

CPU-only build (default) compiles and runs correctly — GPU/TPU paths simply not activated.


Codebase Structure

NietzscheDB/
├── Cargo.toml                ← unified Rust workspace (41 crates)
├── rust-toolchain.toml       ← nightly channel
├── Dockerfile                ← multi-stage production image
├── docker-compose.yaml       ← nietzsche + nietzsche + prometheus + grafana
├── .github/workflows/        ← CI + deploy pipelines
├── crates/
│   ├── nietzsche-core/      ← Poincare HNSW, distance metrics, SIMD
│   ├── nietzsche-vecstore/     ← mmap segments, WAL v3
│   ├── nietzsche-hnsw/     ← HNSW graph, ArcSwap lock-free updates
│   ├── nietzsche-baseserver/    ← gRPC server, multi-tenancy, replication
│   ├── nietzsche-proto/     ← protobuf definitions
│   ├── nietzsche-cli/       ← CLI tools (ratatui TUI)
│   ├── nietzsche-embed/     ← ONNX + remote embedding
│   ├── nietzsche-wasm/      ← WASM / browser / IndexedDB
│   ├── nietzsche-rsdk/       ← NietzscheDB Rust client
│   ├── nietzsche-graph/      ← multi-manifold graph engine     [Phases 1-3]
│   ├── nietzsche-hyp-ops/    ← multi-manifold geometry (Poincaré·Klein·Riemann·Minkowski)
│   ├── nietzsche-query/      ← NQL parser + executor           [Phase 4]
│   ├── nietzsche-lsystem/    ← L-System + Hausdorff pruning    [Phase 5]
│   ├── nietzsche-pregel/     ← heat kernel diffusion           [Phase 6]
│   ├── nietzsche-sleep/      ← sleep/reconsolidation cycle     [Phase 8]
│   ├── nietzsche-zaratustra/ ← autonomous evolution engine     [Phase Z]
│   ├── nietzsche-algo/       ← 11 graph algorithms
│   ├── nietzsche-sensory/    ← sensory compression layer       [Phase 11]
│   ├── nietzsche-cluster/    ← gossip cluster foundation       [Phase G]
│   ├── nietzsche-wiederkehr/ ← DAEMON agents + Will to Power scheduler
│   ├── nietzsche-dream/      ← dream queries (speculative exploration)
│   ├── nietzsche-narrative/  ← narrative engine (story arc detection)
│   ├── nietzsche-agency/     ← autonomous agency + counterfactual engine + TGC
│   ├── nietzsche-rl/         ← PPO reinforcement learning (ONNX inference)
│   ├── nietzsche-neural/     ← neural model registry (ONNX lifecycle)
│   ├── nietzsche-gnn/        ← graph neural network engine
│   ├── nietzsche-mcp/        ← MCP server for AI assistants (20 tools)
│   ├── nietzsche-metrics/    ← Prometheus/OpenTelemetry metrics export
│   ├── nietzsche-filtered-knn/ ← filtered KNN with Roaring Bitmaps
│   ├── nietzsche-named-vectors/ ← multi-vector per node
│   ├── nietzsche-pq/         ← Product Quantization (magnitude-preserving)
│   ├── nietzsche-secondary-idx/ ← secondary indexes by arbitrary field
│   ├── nietzsche-kafka/      ← Kafka Connect sink (CDC streaming)
│   ├── nietzsche-swartz/     ← embedded SQL engine (GlueSQL on RocksDB)
│   ├── nietzsche-media/      ← media/blob store (OpenDAL: S3, GCS, local)
│   ├── nietzsche-api/        ← unified gRPC API (71+ RPCs)
│   ├── nietzsche-sdk/        ← Rust client SDK
│   ├── nietzsche-server/     ← production binary + dashboard
│   ├── nietzsche-hnsw-gpu/   ← GPU vector search (cuVS CAGRA)
│   ├── nietzsche-tpu/        ← TPU vector search (PJRT)
│   └── nietzsche-cugraph/    ← GPU graph traversal (cuGraph)
├── dashboard/                ← React 19 + Cosmograph 2.1 + Tailwind 4
│   ├── src/pages/            ← Overview, Collections, Nodes, Graph, Data, Settings
│   └── dist/                 ← single-file HTML (embedded in binary)
├── sdks/
│   ├── go/                   ← sdk-papa-caolho (71+ RPCs, full coverage)
│   ├── python/               ← gRPC client + proto generation
│   ├── ts/                   ← TypeScript SDK
│   └── cpp/                  ← C++ SDK
├── scripts/                  ← benchmark, build-dashboard, build-wasm, verify
├── benchmarks/               ← reproducible benchmark suite
├── integrations/             ← LangChain Python + JS, LlamaIndex
├── deploy/                   ← Docker, Kubernetes, WIF setup
├── docs/                     ← NQL reference, architecture
└── examples/                 ← HiveMind Tauri app, Python, TypeScript

Build Profiles

# Release (production)
[profile.release]
lto = true
codegen-units = 1
strip = true
panic = "abort"
opt-level = 3

# Bench-fast (CI benchmarks)
[profile.bench-fast]
inherits = "release"
lto = "thin"
codegen-units = 4

# Perf (maximum native CPU optimization)
[profile.perf]
inherits = "release"
# RUSTFLAGS="-C target-cpu=native"

Research Context: The Non-Euclidean Revolution

NietzscheDB closes gaps that no existing database fills. It is built on the realization that Intelligence is not flat.

  • Multi-Manifold Native: While every other vector database (NietzscheDB, Milvus, Pinecone) uses Euclidean or Cosine distance as a flat metric, NietzscheDB operates across 4 non-Euclidean geometries: Poincaré (Hierarchy), Klein (Straight-line Logic), Riemann (Synthesis), and Minkowski (Causality).
  • The Visual Audit Gap: Traditional databases are black boxes. NietzscheDB integrates Perspektive.js as its Visual Cortex, allowing humans to physically see the database manifolds and audit decision-making via the Causal Scrubber.
  • Autonomous Metabolism: NietzscheDB implements a formal Sleep/Reconsolidation Cycle. It doesn't just store data; it organizes it during downtime using Riemannian optimization and Hausdorff identity verification.
  • Dialectical Reasoning: The built-in Hegelian Dialectic Engine allows the database to resolve contradictions by synthesizing opposites into abstract "synthesis" nodes.
  • Emotional Physics: Valence and arousal fields on nodes alter heat diffusion propagation. Knowledge that "matters" (high arousal) spreads faster through the memory, mirroring biological cognitive priority.

🔗 LLM Integration Ecosystem

NietzscheDB provides a multi-layer integration stack for external AI models:

Model Context Protocol (MCP)

AI assistants interact with NietzscheDB as a discoverable tool via JSON-RPC 2.0 (nietzsche-mcp). 20 tools exposed: graph CRUD, NQL query, KNN search, traversal, algorithms, diffusion, stats, force_evolution (epistemology mutations).

Framework Integrations

Framework Module Capabilities
LangChain sdks/python/nietzschedb/langchain.py NietzscheVectorStore — full VectorStore interface, similarity_search_with_score(), RAG pipelines with GPT-4/Claude
LangGraph sdks/python/nietzschedb/langgraph.py NietzscheCheckpointer — persistent agent state, thread-based conversation history. NietzscheMemoryStore — long-term agent memory with TTL and namespace isolation
DSPy sdks/python/nietzschedb/dspy.py NietzscheRM — hybrid BM25 + vector KNN retrieval module
LlamaIndex integrations/ Vector store integration

Embedding Providers

Provider Class Model
OpenAI OpenAIEmbedder text-embedding-3-small
Cohere CohereEmbedder embed-english-v3.0
Voyage AI VoyageEmbedder voyage models
Google GeminiEmbedder Gemini Embedding 2 (text/image/audio/video/PDF → Poincaré, Matryoshka 128–3072D)
HuggingFace SentenceTransformerEmbedder BAAI/bge-m3 (local)
OpenRouter OpenRouterEmbedder OpenAI-compatible API

Gemini Embedding 2 Integration (Multimodal → Poincaré)

Native integration with Google's Gemini Embedding 2 — the first natively multimodal embedding model. Text, images, audio, video, and PDFs are mapped into a unified vector space, then projected into the Poincaré ball via exp_map_zero.

from nietzschedb import NietzscheClient, GeminiEmbedder

embedder = GeminiEmbedder(dim=768)  # Matryoshka: 128/768/1536/3072
client = NietzscheClient("localhost:50051")

# Text → Poincaré (auto exp_map_zero + L2 normalize)
vec = embedder.embed_document("Quantum entanglement enables non-local correlations")
node_id = client.insert_node(coords=vec, content={"text": "..."}, collection="physics")

# Image → same Poincaré space (cross-modal KNN works!)
img_vec = embedder.embed_image("diagram.png")

# Asymmetric retrieval (RETRIEVAL_QUERY vs RETRIEVAL_DOCUMENT)
query_vec = embedder.embed_query("what is entanglement?")
results = client.knn_search(query=query_vec, k=10, collection="physics")

# Precomputed Poincaré via InsertSensory (skip server-side exp_map_zero)
client.insert_sensory(
    node_id=node_id, modality="text", latent=vec,
    precomputed_poincare=True, embedding_model="gemini-embedding-002",
)

# Multimodal (interleaved text + image in same embedding)
multi_vec = embedder.embed_multimodal([
    {"text": "A cat sitting on a mat"},
    {"image": "cat.jpg"},
])

Key features: Matryoshka dimensionality (128→3072 without retraining), 8 task types for optimized retrieval, cross-modal KNN (find images with text queries), precomputed_poincare flag to skip redundant server-side projection.

Code-as-Data (NQL as Executable LLM Output)

LLM-generated NQL queries can be stored as ActionNode graph nodes. When a node's energy exceeds its activation_threshold (via heat diffusion / Will-to-Power), the stored query auto-executes. This transforms the database into a reactive rule engine where LLMs teach the graph autonomous behaviors.

Adaptive Learning Pipeline

Health Metrics → PPO Policy (ONNX) → Growth Strategy → Evolution → Parameter Adjustment
         ↑                                                              │
         └──────────────────── Feedback Loop ───────────────────────────┘
  • Inference at runtime: Pre-trained PPO and GNN models run via ONNX for real-time decisions
  • Offline training: scripts/models/train_ppo.py, train_gnn.py, train_value_network.py
  • 15 adaptive mechanisms: RiemannianAdam, PPO, GNN, AutoTuner, adaptive thresholds, L-System evolution, Will-to-Power, neural threshold daemon, dream engine, reactor, evolution daemon, LTD, thermal perturbation, sensory consolidation, MCTS-based energy boost

Key References & Inspiration

  • Hyperbolic Geometry of Complex Networks (Krioukov et al., 2010)
  • Hyperbolic Neural Networks (Ganea et al., NeurIPS 2018)
  • Riemannian Adaptive Optimization (Becigneul & Ganea, ICLR 2019)
  • Beyond Euclidean Embeddings — The foundation of Nietzsche's Perspectivism as a computational paradigm.

Git Remotes

origin    https://github.com/JoseRFJuniorLLMs/NietzscheDB.git   # NietzscheDB Manifesto repo
upstream  https://github.com/YARlabs/nietzsche-db.git          # Upstream HNSW foundation

License

NietzscheDB is licensed under the AGPL-3.0.
Developed as the memory core for the EVA AGI System.


NietzscheDB
"He who has a why to live can bear almost any how."
Friedrich Nietzsche


GeometricKernels Integration

NietzscheDB integrates the GeometricKernels v1.0 library — a production-ready toolkit for Matérn and Heat kernels on Riemannian manifolds, graphs, and Lie groups — extending its cognitive geometry capabilities with mathematically exact kernels, epistemic uncertainty estimation, and hyperbolic-aware similarity functions.

What It Adds

NietzscheDB Before With GeometricKernels
Heat diffusion via Chebyshev approximation (nietzsche-pregel) Mathematically exact heat kernels as ground truth + calibration
GAUSS_KERNEL(n, t) uses Euclidean distance HYPERBOLIC_HEAT(n, t) — Poincaré-aware heat kernel using geodesic d_P = 2·atanh(‖x‖)
No uncertainty estimation EPISTEMIC_UNCERTAINTY(n) — GP-inspired heuristic for knowledge gap detection
Fixed kernel type MATERN_KERNEL(a, b, ν, κ) — pluggable Matérn (ν=0.5–2.5), Heat (ν=∞), RBF

Architecture

NietzscheDB (Rust)                     GeometricKernels (Python)
┌─────────────────────┐                ┌─────────────────────────┐
│ nietzsche-pregel    │◄── calibrate ──│ Graph Space             │
│ (Chebyshev approx)  │                │ + MaternKarhunenLoeve   │
├─────────────────────┤                ├─────────────────────────┤
│ nietzsche-hyp-ops   │◄── validate ──│ Hyperbolic Space        │
│ (Poincaré/Klein)    │                │ + MaternFeatureMap      │
├─────────────────────┤                ├─────────────────────────┤
│ nietzsche-neural    │◄── ONNX ──────│ Feature Map Export      │
│ (ONNX Runtime)      │                │ (PyTorch → ONNX)        │
├─────────────────────┤                ├─────────────────────────┤
│ nietzsche-agency    │◄── gaps ──────│ GP Uncertainty          │
│ (Evolution Phase 27)│                │ (GPyTorch frontend)     │
└─────────────────────┘                └─────────────────────────┘

Python is NEVER in the hot path — it trains/calibrates offline → exports ONNX → Rust infers at runtime via nietzsche-neural (ort/ONNX Runtime with CUDA). The 3 NQL functions (MATERN_KERNEL, HYPERBOLIC_HEAT, EPISTEMIC_UNCERTAINTY) are 100% Rust with closed-form formulas.

Implementation Status

Phase Status Deliverable
1. Python Foundation Done nietzsche-lab/geometric_service/ — graph bridge, kernel service, calibration
2. Chebyshev Calibration Done ChebyshevCalibrator — compares Chebyshev approx vs exact; finds optimal K_max per cognitive scale
3. Cognitive Uncertainty Done EpistemicUncertaintyEstimator — GPyTorch mode + spectral fallback; knowledge gap detection
4. Hyperbolic Kernels Done HyperbolicKernelService — Matérn on Poincaré ball via hyperboloid; validate_gauss_kernel() for bug analysis
5. ONNX Export Done GeometricFeatureMapExporter — graph features → ONNX embedding lookup (O(1) per node)
6. NQL Extensions Done MATERN_KERNEL(), HYPERBOLIC_HEAT(), EPISTEMIC_UNCERTAINTY() — 100% Rust in nietzsche-query
7. Agency Integration Done GeometricUncertainty intent in nietzsche-agency; scan_geometric_uncertainty() in Evolution27

NQL Examples

-- Matérn similarity (respects Poincaré geodesics)
MATCH (a:Concept), (b:Concept)
RETURN a.title, b.title, MATERN_KERNEL(a, b, 2.5, 1.0) AS similarity
ORDER BY similarity DESC LIMIT 10

-- Corrected hyperbolic heat diffusion (fixes GAUSS_KERNEL Euclidean bug)
MATCH (n:Semantic)
RETURN n.title, HYPERBOLIC_HEAT(n, 1.0) AS heat
ORDER BY heat DESC LIMIT 20

-- Knowledge gap detection
MATCH (n)
WHERE EPISTEMIC_UNCERTAINTY(n) > 0.7
RETURN n.title, EPISTEMIC_UNCERTAINTY(n) AS uncertainty
ORDER BY uncertainty DESC LIMIT 15

Key Design Decisions

  • No Rust port — Python trains/calibrates → ONNX → Rust infers at runtime
  • Chebyshev stays as fast-path for real-time diffusion; GK provides offline ground truth
  • GPyTorch frontend with spectral numpy fallback (no torch dependency required for basic use)
  • Binary Quantization remains REJECTED — geometric kernels depend on magnitude (geodesic distance)

Full roadmap: docs/roadmap/GeometricKernels-Integration.md


Retina of the AGI · Powered by Rust nightly · Perspektive.js 0.1.3 · 4 Manifolds · MCP + gRPC · GPU/TPU · Hegelian Engine

About

NietzscheDB

Resources

License

Unknown, AGPL-3.0 licenses found

Licenses found

Unknown
LICENSE
AGPL-3.0
LICENSE_AGPLv3.md

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors