Expand description
§omgbase-surface
The omgbase surface, Rust implementation of spec/surface: the OQX
query binding over omgbase_store::Store (context, query,
the tier-3 pushdown planner and its translate seam, the
store-backed indexes nested blocks probe — store_index),
the document and block reads (read), the history reads
(history), link health (links), the graph macro (graph), and
the MCP tool catalog as a library (catalog): a table of tools with
JSON-schema inputs and handlers dispatching into the store, with the
error envelope of §4. Transport-agnostic — the omgbase binary serves
catalog::Surface over MCP stdio.
use omgbase_store::Store;
use omgbase_surface::catalog::Surface;
use serde_json::json;
let mut store = Store::open_in_memory()?;
let repo = store.create_repo("notes")?;
let mut surface = Surface::new(store, &repo, None);
let out = surface.call("observe", json!({ "path": "a.md", "content": "# Title\n\nFirst.\n" }));
assert!(!out.is_error);
let res = surface.call("query", json!({ "query": "select $title from docs" }));
assert_eq!(res.body["hits"][0]["$title"], "Title");Re-exports§
pub use catalog::Surface;pub use catalog::ToolOutcome;pub use catalog::ToolSpec;pub use context::StoreContext;pub use context::Target;pub use context::glob_to_like;pub use cursor::decode_cursor;pub use cursor::encode_cursor;pub use error::Result;pub use error::SurfaceError;pub use planner::SqlitePlanner;pub use query::OqxResult;pub use query::QueryOptions;pub use query::collect_semantic_phrases;pub use query::query;pub use query::rewrite_query;pub use version::BuildInfo;pub use version::MCP_PROTOCOL_VERSION;pub use version::version_info;
Modules§
- catalog
- The MCP tool catalog (
spec/surface/README.md§4) as a library: a table ofToolSpecs (name, JSON-schema input, description) and one dispatch (Surface::call) that runs a tool against the store and returns its JSON result or the error envelope. Transport-agnostic — a server wraps each outcome in one text content item. Port ofpackages/core/src/mcp/server.ts. - context
- The query binding (
spec/surface/README.md§1): aDataContextover the store, so theoqxin-memory engine reproduces the whole OQX surface — roots, intrinsics, reach-through, structural relations, the edge graph, the row functions — without a bespoke compiler. Port ofpackages/core/src/oqx-js/context.ts. - cursor
- Keyset cursors (
spec/surface/README.md§1.4):base64url(JSON [parts...]), one encoding for every paged surface —[path, id]forquery,[path]fordocs_list/docs_tree. Decoding requires exactlyaritystring parts; anything else isSurfaceError::cursor_invalidnaming the surface. - error
- The error envelope (
spec/surface/README.md§4):{ error, message, data?, retriable }. Every failure a tool can report is one of these;spec/mutate§8 codes come through unchanged, an OQX or cursor failure isfilter_invalid, and anything unexpected isrepo_not_foundwith its message (§9, pinned). - graph
- The
graphneighborhood macro (spec/surface/README.md§4): compiled to an OQXfollow doc.out/doc.inwalk run through the shared runner and shaped into{ documents, edges, frontier }. Port ofpackages/core/src/mcp/graph.ts; nothing here walks the graph itself. - history
- History (
spec/surface/README.md§3):history_node, the block-graindiff, the Myers unifieddiff_unifiedover the two revisions’ reconstructed files (§3; positional before 1.1, §9),docs_history. Port ofpackages/core/src/graph/history.ts;changes_sinceis the store’s. - links
- Link health (
spec/graph§6,spec/surface§4links_stale): dangling internal links are the open edges whosedst_nodeis aphantom:; external edges are counted, never verified. Port ofpackages/core/src/graph/link-health.ts. - planner
- The tier-3 pushdown planner: reduces the row set a query scans by
translating its pushable top-level
whereconjuncts into ONE SQL statement against the store, then handing the produced rows (plus the untranslatable residual) back to the in-memory engine to finish. Port ofpackages/core/src/oqx-js/planner.tsover theoqxseam (QueryPlanner,Plan,oqx::partition_pushable,oqx::residual_query,oqx::ROWS_ROOT). - query
- The runner (
spec/surface/README.md§1.4): parse the source, rewrite the row functions to$selfmethods, run it through the engine over the store context, and shape the engine’s result into the surface’sOqxResult(lean{ id, path, … }hits, keyset paging, the consumer scalars). Port ofpackages/core/src/oqx-js/run.ts. - read
- Reads (
spec/surface/README.md§2): ref resolution, whole-document reads, block hydration at a resolution, the outline wire format, and the two path-ordered list surfaces. Port ofpackages/core/src/core/read/*. Result keys follow the reference’s spelling (docId,renderedHashMatch, …) — the fixtures are generated from it. - reference
- The
query_syntaxtext (spec/surface/README.md§4: reference prose, unpinned). A condensed distillation ofdocs/query-language.md. - store_
index - Store-backed equality indexes for the OQX engine (
DataContext::index_for): when a nested block’s receiver is a ROOT SCAN ($repo.docs,$repo.edges, a baredocsat the root scope — a lazycrate::contextmarker) and its correlated or constant equality is on a column or property SQLite can look up —where $path == ^^$path,where customer == ^$path,where $dst == ^$id,where type == "order"— the probe runs ONE cached statement against the store’s indexes instead of materializing every row of the target and hashing it. The rows come back exactly as the root scan constructs them (same columns, same__path, same tag, same(path, id)order) under the same live-row and repo guards as the planner’s, so every intrinsic and relation keeps working downstream and the result cannot differ from the scan — only the work does. Port ofpackages/core/src/oqx-js/store-index.ts. - translate
- Semantics-faithful OQX expression → SQLite translator: the pushdown seam
of the tier-3 planner (
crate::planner). Port ofpackages/core/src/oqx-js/sql/translate.ts. - version
- The
versiontool (spec/surface§4, 1.4): which engine and which versions — the serving binary’s own, every component crate’s, the spec versions they were built against, the database schema, the MCP protocol, the runtime, the build’s commit and time.
Constants§
- SPEC_
VERSION - The
spec/surface/VERSIONthis crate implements (major.minor). - VERSION
- This crate’s own version (
Cargo.toml), for the surface’sversiontool.