Expand description
AINL Memory - Graph-based agent memory substrate
Graph-as-memory for AI agents. Execution IS the memory.
AINL Memory 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.
§Quick Start
use ainl_memory::GraphMemory;
use std::path::Path;
let memory = GraphMemory::new(Path::new("memory.db")).unwrap();
// Record an episode
memory.write_episode(
vec!["file_read".to_string(), "agent_delegate".to_string()],
Some("agent-B".to_string()),
None,
).unwrap();
// Recall recent episodes
let recent = memory.recall_recent(100).unwrap();§Architecture
AINL Memory is designed as infrastructure that any agent framework can adopt:
- Zero dependencies on specific agent runtimes
- Simple trait-based API via
GraphStore - Bring your own storage backend
§Graph store: query, export, validation (since 0.1.4-alpha)
SqliteGraphStore: SQLite backend withPRAGMA foreign_keys = ON,FOREIGN KEYconstraints onainl_graph_edges, one-time migration for legacy DBs (see CHANGELOG.md).GraphQuery:store.query(agent_id)— agent-scoped SQL helpers (episodes, lineage, tags, …).- Snapshots:
AgentGraphSnapshot,SnapshotEdge,SNAPSHOT_SCHEMA_VERSION;SqliteGraphStore::export_graph/SqliteGraphStore::import_graph(strict vs repair viaallow_dangling_edges). - Validation:
GraphValidationReport,DanglingEdgeDetail;SqliteGraphStore::validate_graphfor agent-scoped semantics beyond raw FK enforcement. GraphMemoryforwards the above where hosts should not reach past the facade (see impl block).
§Node Types
- Episode: What happened during an agent turn (tool calls, delegations)
- Semantic: Facts learned with confidence scores
- Procedural: Reusable compiled workflow patterns
- Persona: Agent traits learned over time
- Runtime state (
RuntimeStateNode,node_type = runtime_state): Optional persisted session counters and persona snapshot JSON for ainl-runtime (seeGraphMemory::read_runtime_state/GraphMemory::write_runtime_state).
Re-exports§
pub use node::AinlEdge;pub use node::AinlMemoryNode;pub use node::AinlNodeKind;pub use node::AinlNodeType;pub use node::EpisodicNode;pub use node::MemoryCategory;pub use node::PersonaLayer;pub use node::PersonaNode;pub use node::PersonaSource;pub use node::ProceduralNode;pub use node::ProcedureType;pub use node::RuntimeStateNode;pub use node::SemanticNode;pub use node::Sentiment;pub use node::StrengthEvent;pub use query::count_by_topic_cluster;pub use query::find_high_confidence_facts;pub use query::find_patterns;pub use query::find_strong_traits;pub use query::recall_by_procedure_type;pub use query::recall_by_topic_cluster;pub use query::recall_contradictions;pub use query::recall_delta_by_relevance;pub use query::recall_episodes_by_conversation;pub use query::recall_episodes_with_signal;pub use query::recall_flagged_episodes;pub use query::recall_low_success_procedures;pub use query::recall_recent;pub use query::recall_strength_history;pub use query::walk_from;pub use query::GraphQuery;pub use snapshot::AgentGraphSnapshot;pub use snapshot::DanglingEdgeDetail;pub use snapshot::GraphValidationReport;pub use snapshot::SnapshotEdge;pub use snapshot::SNAPSHOT_SCHEMA_VERSION;pub use store::GraphStore;pub use store::SqliteGraphStore;
Modules§
- node
- AINL graph node types - the vocabulary of agent memory.
- query
- Graph traversal and querying utilities.
- snapshot
- Serializable graph snapshots and validation reports.
- store
- Graph storage backends for AINL memory.
Structs§
- Graph
Memory - High-level graph memory API - the main entry point for AINL memory.