| Crates.io | anda_cognitive_nexus |
| lib.rs | anda_cognitive_nexus |
| version | 0.6.5 |
| created_at | 2025-07-07 08:37:45.941597+00 |
| updated_at | 2026-01-22 09:12:30.04427+00 |
| description | A Rust implementation of KIP (Knowledge Interaction Protocol) base on Anda DB. |
| homepage | |
| repository | https://github.com/ldclabs/anda_db/tree/main/rs/anda_cognitive_nexus |
| max_upload_size | |
| id | 1740892 |
| size | 304,500 |
Anda Cognitive Nexus is a Rust implementation of KIP (Knowledge Interaction Protocol) built on top of anda_db. It provides a persistent, graph-based long-term memory substrate for AI agents (concepts + propositions) with a KIP executor API.
Links:
KIP (Knowledge Interaction Protocol) is a specialized protocol designed for Large Language Models (LLMs). It establishes a standard for efficient, reliable, and bidirectional knowledge exchange between an LLM (the "neural core") and a knowledge graph (the "symbolic core"). This allows AI Agents to build a memory that is not only queryable but also auditable and capable of evolution.
Drug named "Aspirin"). Each node has a type, a name, attributes, and metadata.(subject, predicate, object) structure (e.g., (Aspirin, treats, Headache)).anda_kip.Add dependencies to your Cargo.toml (pick a concrete object_store backend):
[dependencies]
anda_cognitive_nexus = "0.6"
anda_kip = "0.6"
tokio = { version = "1", features = ["full"] }
# Provide an ObjectStore implementation
object_store = { version = "0.13", features = ["fs"] }
# Optional (recommended for local filesystem): metadata + conditional put support
anda_object_store = "0.3"
This example boots a Nexus on an in-memory object store, inserts a small capsule via KML, and queries it via KQL.
use anda_cognitive_nexus::{CognitiveNexus, KipError};
use anda_db::database::{AndaDB, DBConfig};
use anda_kip::{parse_kml, parse_kql};
use object_store::memory::InMemory;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), KipError> {
// 1) Set up storage and database
let db = AndaDB::connect(Arc::new(InMemory::new()), DBConfig::default()).await?;
// 2) Connect to the Cognitive Nexus
let nexus = CognitiveNexus::connect(Arc::new(db), async |_nexus| Ok(()) ).await?;
println!("Connected to Anda Cognitive Nexus: {}", nexus.name());
// 3) Manipulate Knowledge with KML
let kml_string = r#"
UPSERT {
CONCEPT ?drug_type {
{type: "$ConceptType", name: "Drug"}
SET ATTRIBUTES { description: "Pharmaceutical drug concept type" }
}
CONCEPT ?symptom_type {
{type: "$ConceptType", name: "Symptom"}
SET ATTRIBUTES { description: "Medical symptom concept type" }
}
CONCEPT ?treats_relation {
{type: "$PropositionType", name: "treats"}
SET ATTRIBUTES { description: "Drug treats symptom relationship" }
}
CONCEPT ?headache {
{type: "Symptom", name: "Headache"}
SET ATTRIBUTES { severity_scale: "1-10", description: "Pain in the head or neck area" }
}
CONCEPT ?aspirin {
{type: "Drug", name: "Aspirin"}
SET ATTRIBUTES { molecular_formula: "C9H8O4", risk_level: 1 }
SET PROPOSITIONS {
("treats", {type: "Symptom", name: "Headache"})
}
}
}
WITH METADATA { source: "Basic Medical Knowledge" }
"#;
let kml_commands = parse_kml(kml_string)?;
let kml_result = nexus.execute_kml(kml_commands, false).await?;
println!("KML Execution Result: {:#?}", kml_result);
// 4) Query Knowledge with KQL
let kql_query = r#"
FIND(?drug.name, ?drug.attributes.risk_level)
WHERE {
?drug {type: "Drug"}
(?drug, "treats", {type: "Symptom", name: "Headache"})
}
"#;
let (kql_result, _) = nexus.execute_kql(parse_kql(kql_query)?).await?;
println!("KQL Query Result: {:#?}", kql_result);
nexus.close().await?;
Ok(())
}
If you want a single structured interface (handy for function calling), use anda_kip::Request / Response. This is also what anda_cognitive_nexus_server expects under POST /kip with method=execute_kip.
use anda_kip::{Request, Response};
let req = Request {
command: "DESCRIBE PRIMER".to_string(),
..Default::default()
};
let (_ty, resp): (_, Response) = req.execute(&nexus).await;
println!("{resp:?}");
This repository includes a comprehensive demo: https://github.com/ldclabs/anda-db/tree/main/rs/anda_cognitive_nexus/examples/kip_demo.rs
To run it:
mkdir -p ./debug/metastore
cargo run -p anda_cognitive_nexus --example kip_demo
anda_kip: parser + request/response model for KIP.anda_db: embedded storage engine.anda_cognitive_nexus_server: expose KIP over HTTP (JSON-RPC).Copyright © 2026 LDC Labs.
ldclabs/anda-db is licensed under the MIT License. See LICENSE for the full license text.