fastmemory 0.1.0

A CBFDAE Ontological Clustering Engine for AI Agent Memory
Documentation
# FastMemory

**FastMemory** is an ontological clustering engine that transforms flat, unstructured text embeddings into a structured, agent-navigable functional memory graph using the **CBFDAE** (Component, Block, Function, Data, Access, Event) taxonomy.

Developed by [FastBuilder.AI](https://fastbuilder.ai), FastMemory bridges the gap between shallow vector retrieval (RAG) and deterministic computational memory.

---

## πŸ—ΊοΈ The Google Maps Analogy

Imagine opening Google Maps, but all you can see are roads and paths. There are no building names, no entry gates, no transaction information for the buildings, and no communication routing.

If you asked a humanoid robot to navigate to a hospital using this map, it would only see a "road to a doctor", a "road to a bed", a "road to a nurse", and a "road to a pharmacy." It would have a profoundly hard time knowing the modes and modality of how to actually behave, act, and pursue every target differently depending on context.

**That is exactly what happens when you use standard RAG, semantic ontologies, or flat vector graphs.**

|                   Standard Ontology / RAG                   |                      FastMemory CBFDAE Map                       |
| :---------------------------------------------------------: | :--------------------------------------------------------------: |
| <img src="example/analogies/roads_only.png" width="100%" /> | <img src="example/analogies/structured_city.png" width="100%" /> |

You simply have node-to-node semantic edges. You possess the "roads" (cosine similarity), but you lack the "buildings" (Functional Components) and the "rules of entry/engagement" (Access and Events).

**FastMemory** solves this. We utilize high-speed Community Detection (Louvain clustering) to mathematically derive and enhance this network of data for **direct AI usage**, translating raw text into executable cognitive blocks.

---

## πŸ” Features & Benefits

- **CBFDAE Ontology**: Information isn't just stored; it is classified into **C**omponents, **B**locks, **F**unctions, **D**ata, **A**ccess restrictions, and **E**vents.
- **Deterministic Pathfinding**: Eliminates RAG hallucinations. An AI doesn't "guess" the answer based on semantic proximity; it traverses a rigorous, rule-based logic graph.
- **The Agentic Query Engine**: Deep recursive subtree targeting. When you query FastMemory, it doesn't just return a matching stringβ€”it returns the _deepest logical encompassing Block_, providing the AI with sibling functions and contextual boundaries.
- **Enterprise Native**: Designed to sit on top of Datawarehouses, SAP, Databricks, AWS Glue, and Fabric.

---

## πŸ“Š Before & After FastMemory

Standard vector RAG databases index chunks individually, often losing the multi-hop reasoning capability required to trace dependencies. FastMemory restructures these into event-driven, hierarchical memory blocks.

_(You can open the interactive D3.js visualizations directly in your browser from the `example/` directories!)_

### πŸ₯ Health Science

|                Before: Flat Semantic Vectors                 |          After: Clustered Functional Memory Graph           |
| :----------------------------------------------------------: | :---------------------------------------------------------: |
| <img src="example/health_science/before.png" width="100%" /> | <img src="example/health_science/after.png" width="100%" /> |

### πŸ€– Robotics

|             Before: Flat Semantic Vectors              |       After: Clustered Functional Memory Graph        |
| :----------------------------------------------------: | :---------------------------------------------------: |
| <img src="example/robotics/before.png" width="100%" /> | <img src="example/robotics/after.png" width="100%" /> |

### πŸš— Driverless Cars

|                 Before: Flat Semantic Vectors                 |           After: Clustered Functional Memory Graph           |
| :-----------------------------------------------------------: | :----------------------------------------------------------: |
| <img src="example/driverless_cars/before.png" width="100%" /> | <img src="example/driverless_cars/after.png" width="100%" /> |

### πŸ“ˆ Business Analytics

|                  Before: Flat Semantic Vectors                   |            After: Clustered Functional Memory Graph             |
| :--------------------------------------------------------------: | :-------------------------------------------------------------: |
| <img src="example/business_analytics/before.png" width="100%" /> | <img src="example/business_analytics/after.png" width="100%" /> |

### βœ‰οΈ Email Analysis

|                Before: Flat Semantic Vectors                 |          After: Clustered Functional Memory Graph           |
| :----------------------------------------------------------: | :---------------------------------------------------------: |
| <img src="example/email_analysis/before.png" width="100%" /> | <img src="example/email_analysis/after.png" width="100%" /> |

### πŸ“‹ Audit Operations

|            Before: Flat Semantic Vectors            |      After: Clustered Functional Memory Graph      |
| :-------------------------------------------------: | :------------------------------------------------: |
| <img src="example/audit/before.png" width="100%" /> | <img src="example/audit/after.png" width="100%" /> |

### 🌍 World Events

|               Before: Flat Semantic Vectors                |         After: Clustered Functional Memory Graph          |
| :--------------------------------------------------------: | :-------------------------------------------------------: |
| <img src="example/world_events/before.png" width="100%" /> | <img src="example/world_events/after.png" width="100%" /> |

---

## πŸ“¦ Installation

**Rust (Cargo)**
FastMemory is officially published on crates.io. You can install the highly concurrent CLI binary directly:
```bash
cargo install fastmemory
```

**Python (PyPI)**
FastMemory provides Python bindings via PyO3, allowing you to build and traverse CBFDAE structures natively in Python:
```bash
pip install fastmemory
```

---

## πŸš€ Usage Guide

FastMemory can be used as a standalone binary, a compiled Cargo crate, or a Python package via PyO3.

### 1. Standalone Binary / Cargo Crate

```bash
# Build the memory graph from an ATF Markdown file
$ fastmemory build data/input.md

# Instantly query the hierarchical graph
$ fastmemory query data/input.md "reimbursement"
```

### 2. Running as an Enterprise Service

FastMemory ships with a highly optimized embedded Axum web server and MCP (Model Context Protocol) integration for AI agents:

```bash
# Boot the REST API locally or enterprise-wide
$ fastmemory serve data/input.md --port 16743
# Query: curl http://localhost:16743/query?q=reimbursement

# Boot standard Stdio MCP (for Claude / Gemini IDE integration)
$ fastmemory mcp data/input.md
```

### 3. Data Ingestion

- **Local Ingestion**: Use the file argument directly (`fastmemory build <file.md>`).
- **Enterprise Pipeline**: _(Upcoming)_ You can utilize the `-data` flag for dynamic ingestion, or the `-datahost` flag to bind directly to enterprise data lakes like Snowflake, BigQuery, or Databricks.

### 4. Advanced Security & Federated Auth

Data access within FastMemory is rigorously secured at the graph layer. Utilizing the **`A_` (Access)** node topology, you can map federated IAM rules (like AWS IAM or Azure AD) directly onto specific memory blocks.

- **Wrapper Implementation**: Place an API Gateway ahead of `fastmemory serve` to enforce standard OAuth/SAML.
- **Code-Level Auth**: AI agents parsing the memory graph will inherently see the `A_Role_Admin` nodes attached to functions, allowing the agent to deterministically self-regulate access before taking action.

---

## 🧠 Applications

| Standard RAG Robot Brain | FastMemory CBFDAE Robot Brain |
| :---: | :---: |
| <img src="example/analogies/robot_rag_memory.png" width="100%" /> | <img src="example/analogies/robot_fast_memory.png" width="100%" /> |

- **Agentic Apps & SaaS**: Integrate `fastmemory mcp` directly into your proprietary AI loops. Instead of sending agents to vector DBs, send them into a FastMemory graph where they can extract isolated, functional context blocks to execute SaaS workflows.
- **Fast Software Engineering**: In [FastBuilder.AI]https://fastbuilder.ai, FastMemory acts as the structural brain for rapid feature development. By indexing the entire application architecture into an ontological graph, coding agents can query precisely how a proposed change will impact distant, decoupled components.
- **The Possibilities are Endless**: Medical diagnostics routing, autonomous drone navigation logic, enterprise compliance auditing, etc.

---

## πŸ“„ License & Commercial Terms

This project is licensed under the **MIT License**.

**COMMERCIAL USE EXCEPTION**
Notwithstanding the MIT License, any commercial entity, company, or organization that has generated gross revenue exceeding **USD $20,000,000** in its most recently completed fiscal year or current interim year must obtain an explicit commercial license from FastBuilder.AI prior to using, copying, modifying, merging, publishing, distributing, sublicensing, or selling copies of this Software.