Skip to main content

mini_app_core/
lib.rs

1//! # mini-app-core
2//!
3//! Agent-First CRUD store core library. Transport-agnostic DB layer that
4//! drives one table per process from `schema.yaml`, backed by SQLite.
5//!
6//! Transport (MCP / HTTP / CLI) lives in a separate crate (`mini-app-mcp`)
7//! that depends on this one. The dependency is strictly one-way:
8//! `mcp → core`, never the reverse. Error type conversion to `rmcp::ErrorData`
9//! is performed by an ACL adapter (private free function) in the mcp crate to
10//! comply with the Rust orphan rule (Outline rust book §5-1-10 K-orphan-rule).
11
12/// Schema definition, runtime loading, and JSON row validation.
13pub mod schema;
14
15/// Application-level error type.
16pub mod error;
17
18/// Runtime configuration loaded from environment variables.
19pub mod config;
20
21/// SQLite-backed row store (async CRUD via `tokio::task::spawn_blocking`).
22pub mod store;
23
24/// Update semantics for [`store::Store::update`]: [`UpdateMode::Merge`] (default,
25/// RFC 7396 shallow merge) or [`UpdateMode::Replace`] (full replacement).
26pub use store::UpdateMode;
27
28/// Server-side row filter for the `list` tool.
29pub mod filter;
30
31/// Server-side ORDER BY primitive for the `list` tool.
32///
33/// Provides [`order_by::OrderByItem`] (field + direction pair) and
34/// [`order_by::Direction`] (`Asc` / `Desc`), along with
35/// [`order_by::validate_order_by`] (schema-whitelist check) and
36/// [`order_by::build_order_by_sql`] (infallible SQL clause builder).
37pub mod order_by;
38
39/// Multi-table aggregation primitives (`query_aggregate` tool backend).
40///
41/// Provides `AliasAggregator` (Count / Sum / Avg / Min / Max / GroupBy),
42/// `SourceSpec` (Single / Multi), `AliasRunResult` (Rows / Count / Value /
43/// Groups), and `execute_aggregate` for SQLite ATTACH DATABASE + UNION ALL
44/// composition across per-table `.db` files.
45pub mod aggregator;
46
47/// Multi-table registry + atomic reload (Arc-Swap based, K-110-compliant).
48pub mod registry;
49
50/// Global alias storage (Phase 2). Persists named queries that span
51/// Single / Multi / Pattern table sources in a dedicated
52/// `<project_dir or user_dir>/_global.db` SQLite file, separate from
53/// per-table `<table>.db`. Provides lookup with Project → User
54/// precedence and a lossless migration helper from legacy per-table
55/// `_aliases` storage.
56pub mod alias_storage;
57
58/// `row_materialize` operation — row selection, field projection, and
59/// multi-format filesystem output with SHA-256 integrity digest.
60pub mod materialize;
61
62/// Framework-level dump hook utilities (write-only file materialization).
63pub mod dump;
64
65/// Backup utilities (YAML + SQLite online backup with retention).
66pub mod backup;
67
68/// Snapshot utilities (SQLite-only online snapshot with retention).
69pub mod snapshot;
70
71/// Top-level orchestration for `alias_run` — single entry point exposed for
72/// both the MCP tool handler and direct SDK consumers.
73pub mod alias_run;
74
75/// Row-level change history (`_row_history` table).
76///
77/// Records every `create`, `update`, and `delete` atomically (same SQLite
78/// transaction as the data DML).  Exposes [`row_history::ensure_history_table`],
79/// [`row_history::record_in_tx`], [`row_history::fetch_at`],
80/// [`row_history::list_versions`], and [`row_history::purge_old_history`].
81pub mod row_history;
82
83/// Re-export of [`error::MiniAppError`] for convenient `use mini_app_core::MiniAppError`.
84pub use error::MiniAppError;