omgbase_surface/lib.rs
1//! # omgbase-surface
2//!
3//! The omgbase surface, Rust implementation of `spec/surface`: the OQX
4//! **query binding** over [`omgbase_store::Store`] ([`context`], [`mod@query`],
5//! the tier-3 pushdown [`planner`] and its [`translate`] seam),
6//! the document and block **reads** ([`read`]), the **history** reads
7//! ([`history`]), link health ([`links`]), the `graph` macro ([`graph`]), and
8//! the **MCP tool catalog** as a library ([`catalog`]): a table of tools with
9//! JSON-schema inputs and handlers dispatching into the store, with the
10//! error envelope of §4. Transport-agnostic — the `omgbase` binary serves
11//! [`catalog::Surface`] over MCP stdio.
12//!
13//! ```
14//! use omgbase_store::Store;
15//! use omgbase_surface::catalog::Surface;
16//! use serde_json::json;
17//!
18//! let mut store = Store::open_in_memory()?;
19//! let repo = store.create_repo("notes")?;
20//! let mut surface = Surface::new(store, &repo, None);
21//! let out = surface.call("observe", json!({ "path": "a.md", "content": "# Title\n\nFirst.\n" }));
22//! assert!(!out.is_error);
23//! let res = surface.call("query", json!({ "query": "select $title from docs" }));
24//! assert_eq!(res.body["hits"][0]["$title"], "Title");
25//! # Ok::<(), omgbase_store::Error>(())
26//! ```
27
28#![forbid(unsafe_code)]
29// The error envelope carries a code, a message and an optional JSON `data`
30// (~128 bytes); every failure is a cold path at the tool boundary, so the
31// `Result` size is not worth boxing.
32#![allow(clippy::result_large_err)]
33
34pub mod catalog;
35pub mod context;
36pub mod cursor;
37pub mod error;
38pub mod graph;
39pub mod history;
40pub mod links;
41pub mod planner;
42pub mod query;
43pub mod read;
44pub mod reference;
45pub mod translate;
46
47pub use catalog::{Surface, ToolOutcome, ToolSpec};
48pub use context::{StoreContext, Target, glob_to_like};
49pub use cursor::{decode_cursor, encode_cursor};
50pub use error::{Result, SurfaceError};
51pub use planner::SqlitePlanner;
52pub use query::{OqxResult, QueryOptions, collect_semantic_phrases, query, rewrite_query};
53
54/// The `spec/surface/VERSION` this crate implements (`major.minor`).
55pub const SPEC_VERSION: &str = "1.1";