ainl-memory 0.1.0-alpha

AINL graph-memory substrate - agent memory as execution graph
Documentation
# AINL Memory - Graph-Based Agent Memory Substrate

**Graph-as-memory for AI agents. Execution IS the memory.**

AINL Memory is a Rust library that implements agent memory as an execution graph. Every agent turn, tool call, and delegation becomes a typed graph node. No separate retrieval layer—the graph itself is the memory.

## Why AINL Memory?

Most agent frameworks treat memory as separate from execution:
- Execute → Store text → Retrieve → Execute again
- Separate episodic, semantic, and procedural stores
- Memory retrieval adds latency and complexity

AINL Memory unifies execution and memory:
- **Episodic memory**: What happened during agent turns (tool calls, delegations)
- **Semantic memory**: Facts learned with confidence scores
- **Procedural memory**: Reusable compiled workflow patterns
- **Persona memory**: Agent traits learned over time

All stored as typed graph nodes with edges for traversal.

## Quick Start

```toml
[dependencies]
ainl-memory = "0.1.0-alpha"
```

```rust
use ainl_memory::{AinlMemoryNode, SqliteGraphStore, GraphStore};

// Open a graph store
let store = SqliteGraphStore::open("memory.db").unwrap();

// Record an agent delegation
let node = AinlMemoryNode::new_delegation_episode(
    "agent-A".to_string(),
    "agent-B".to_string(),
    "trace-123".to_string(),
    1, // depth
);

store.write_node(&node).unwrap();

// Query recent episodes
let episodes = store.query_recent_episodes("agent-A", 10).unwrap();
```

## Features

- **Typed graph nodes**: Episode, Semantic, Procedural, Persona
- **SQLite backend**: Persistent graph storage with indexes
- **Graph traversal**: Walk edges between nodes
- **Swappable backends**: Implement `GraphStore` trait for custom storage
- **Zero unsafe code**: Pure Rust implementation
- **Offline-first**: No network required, local SQLite storage

## Node Types

### Episode
Records what happened during an agent turn:
- Tool calls executed
- Delegation to other agents
- Trace ID for correlation
- Delegation depth

### Semantic
Facts learned with confidence:
- Fact text
- Confidence score (0.0-1.0)
- Source turn ID

### Procedural
Reusable workflow patterns:
- Pattern name
- Compiled graph (binary format)

### Persona
Agent traits learned over time:
- Trait name
- Strength (0.0-1.0)
- Source turn IDs

## Architecture

AINL Memory is designed as infrastructure that any agent framework can adopt:
- No dependencies on specific agent runtimes
- Simple trait-based API
- Bring your own storage backend

## Status

**Alpha (0.1.0-alpha)**

API is subject to change. Production-ready for experimentation.

## License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT]LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

## Contributing

Contributions are welcome! This is early-stage infrastructure—your feedback shapes the API.

## See Also

- [ainl-runtime]https://crates.io/crates/ainl-runtime - AINL execution runtime (coming soon)
- [AINL Specification]https://github.com/sbhooley/ainativelang - AI Native Language design