Skip to main content

Crate anda_cognitive_nexus

Crate anda_cognitive_nexus 

Source
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}, carrying attributes and metadata.
  • 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

See the technical reference at docs/anda_cognitive_nexus.md for the full storage layout, indexing strategy, and KIP semantics.

Re-exports§

pub use db::*;
pub use entity::*;

Modules§

db
Cognitive Nexus Module
entity
Entity Module

Structs§

GraphPath
Represents a path through the knowledge graph.
PropositionsMatchResult
Result structure for proposition matching operations.
QueryCache
Thread-safe cache for storing loaded entities during query execution.
QueryContext
Query execution context for managing variable bindings and caching.
QueryRelationBinding
Variables attached to the rows emitted by one proposition clause.
QueryRelationRow
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.
TargetEntities
Specifies the target entities for query operations.

Traits§

FilterExpressionExt
Extension trait for FilterExpression to 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.