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 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;
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_unified(§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. - 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.
Constants§
- SPEC_
VERSION - The
spec/surface/VERSIONthis crate implements (major.minor).