gollum_kb_oc/lib.rs
1//! `gollum-kb-oc` — OpenCypher / GQLite knowledge-base backend for Gollum.
2//!
3//! Implements [`gollum_kb::KnowledgeBase`] and [`gollum_kb::FactProvider`] on
4//! top of [GQLite](https://gitlab.com/auksys/gqlite), an embeddable graph
5//! database that speaks OpenCypher.
6//!
7//! # Schema
8//!
9//! Each Gollum predicate `name/N` is stored as a labelled node:
10//!
11//! ```cypher
12//! CREATE (:parent {_arity: 2, arg0: 'alice', arg1: 'bob'})
13//! ```
14//!
15//! Reasoning metadata (probability, temporal interval, modal annotation, …) is
16//! stored as additional reserved properties prefixed with `_`. See
17//! [`translator`] for the full schema reference.
18//!
19//! # Example
20//!
21//! ```rust,no_run
22//! use gollum_ir::{IrClause, IrQuery, IrTerm};
23//! use gollum_kb::KnowledgeBase;
24//! use gollum_kb_oc::GqliteKb;
25//! use futures::StreamExt as _;
26//!
27//! # #[tokio::main]
28//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
29//! let mut kb = GqliteKb::new_in_memory()?;
30//!
31//! // Store a fact: parent(alice, bob)
32//! kb.assert_fact(IrClause {
33//! head: IrTerm::Structure {
34//! name: "parent".into(),
35//! args: vec![IrTerm::Atom("alice".into()), IrTerm::Atom("bob".into())],
36//! },
37//! body: vec![],
38//! metadata: None,
39//! }).await?;
40//!
41//! // Query: parent(X, bob)
42//! let mut stream = kb.query(&IrQuery {
43//! goal: IrTerm::Structure {
44//! name: "parent".into(),
45//! args: vec![IrTerm::Var("X".into()), IrTerm::Atom("bob".into())],
46//! },
47//! metadata: None,
48//! }).await?;
49//!
50//! while let Some(Ok(sol)) = stream.next().await {
51//! println!("X = {:?}", sol.get("X"));
52//! }
53//! # Ok(()) }
54//! ```
55
56pub mod async_pred;
57pub mod error;
58pub mod kb;
59pub mod mapper;
60pub mod translator;
61
62pub use async_pred::GqliteAsyncPredicate;
63pub use error::OcError;
64pub use kb::GqliteKb;
65pub use translator::SchemaMode;