Expand description
§anda_cognitive_nexus
A reference implementation of the Knowledge Interaction Protocol (KIP)
Executor backed by Anda DB.
The crate exposes a single high-level type, CognitiveNexus, which
manages a persistent knowledge graph of:
- Concept nodes (
Concept) — identified by{type, name}, carryingattributesandmetadata. - Proposition links (
Proposition) — directed triples(subject, predicate, object)where subject/object may themselves be propositions (higher-order facts). Each row stores all of its predicates in a single record to keep the link space compact.
CognitiveNexus accepts the full KIP v1.0-RC7 grammar — KQL queries
(FIND … WHERE …), KML mutations (UPSERT, DELETE …) and META
introspection (DESCRIBE …, SEARCH …) — and translates them into
Anda DB collection operations using a small, well-defined index plan
(BTree + BM25 over the concepts and propositions collections).
§Quick start
ⓘ
use std::sync::Arc;
use anda_db::database::{AndaDB, DBConfig};
use anda_cognitive_nexus::CognitiveNexus;
use object_store::memory::InMemory;
let db = AndaDB::connect(Arc::new(InMemory::new()), DBConfig::default())
.await
.map_err(anda_cognitive_nexus::db_to_kip_error)?;
let nexus = CognitiveNexus::connect(Arc::new(db), async |_| Ok(())).await?;
// Run any KIP command via the [`anda_kip::Executor`] trait.
use anda_kip::{parse_kml, parse_kql};
nexus.execute_kml(parse_kml(r#"
UPSERT {
CONCEPT ?d { {type: "$ConceptType", name: "Drug"} }
}
"#)?, false).await?;§Module layout
db— theCognitiveNexustype and KIP executor implementation.entity— persisted graph data model (Concept,Proposition,EntityID,Properties).helper— small extraction / sorting / error-mapping utilities (extract_concept_field_value,apply_order_by,db_to_kip_error, …).types— query-execution scaffolding (ConceptPK,PropositionPK,EntityPK,QueryContext,TargetEntities).
See the technical reference at docs/anda_cognitive_nexus.md for the
full storage layout, indexing strategy, and KIP semantics.
Re-exports§
Modules§
Structs§
- Graph
Path - Represents a path through the knowledge graph.
- Propositions
Match Result - Result structure for proposition matching operations.
- Query
Cache - Thread-safe cache for storing loaded entities during query execution.
- Query
Context - Query execution context for managing variable bindings and caching.
- Query
Relation Binding - Variables attached to the rows emitted by one proposition clause.
- Query
Relation Row - One concrete proposition-clause match.
Enums§
- ConceptPK
- Primary key for identifying concepts in the cognitive nexus.
- EntityPK
- Unified primary key for any entity in the cognitive nexus.
- PropositionPK
- Primary key for identifying propositions in the cognitive nexus.
- Target
Entities - Specifies the target entities for query operations.
Traits§
- Filter
Expression Ext - Extension trait for
FilterExpressionto check for unbound variables.
Functions§
- apply_
order_ by - Applies sorting to entity-value pairs based on order conditions.
- db_
to_ kip_ error - Converts database errors to KIP errors.
- extract_
concept_ field_ value - Extracts field values from a concept using a dot-notation path.
- extract_
proposition_ field_ value - Extracts field values from a proposition using a dot-notation path.
- match_
predicate_ against_ proposition - Matches a predicate term against a proposition.