Skip to main content

oxide_mirror/
lib.rs

1//! # `oxide-mirror` — Local, Event-Sourced Data Mirror
2//!
3//! `oxide-mirror` keeps a SQLite-backed local copy of remote API data so AI
4//! agents can run complex SQL queries (joins, aggregations, time-window
5//! filters) across many services without paying the latency or rate-limit
6//! cost of going over the wire every time.
7//!
8//! The crate is organised around four cooperating pieces:
9//!
10//! * [`event`] — the durable, append-only [`Delta`](event::Delta) log shape
11//!   that every sync source emits. Each delta carries an explicit
12//!   [`Provenance`](event::Provenance) (source id + confidence) so callers can
13//!   reason about who wrote what.
14//! * [`source`] — the [`SyncSource`](source::SyncSource) trait that
15//!   `oxide-gen` generated clients implement. A source knows how to pull a
16//!   batch of deltas starting from a cursor and to advance the cursor when
17//!   the batch has been applied.
18//! * [`store`] — [`MirrorStore`](store::MirrorStore) owns the SQLite pool,
19//!   the schema migrations, the event log, the materialised
20//!   [`MirroredRecord`](event::MirroredRecord) table, and the per-source
21//!   cursor table. Exposes [`MirrorStore::query`] for read-only SQL.
22//! * [`sync`] — [`Syncer`](sync::Syncer) ties the previous two together,
23//!   pulling deltas from a `SyncSource`, applying them through a
24//!   [`ConflictStrategy`](conflict::ConflictStrategy), and persisting the
25//!   new cursor.
26//!
27//! [`kernel::MirrorModule`] wires everything into the `oxide-k` kernel so
28//! sync runs and queries can be triggered via the kernel message bus.
29
30#![deny(rust_2018_idioms)]
31#![warn(missing_docs)]
32
33pub mod conflict;
34pub mod error;
35pub mod event;
36pub mod kernel;
37pub mod source;
38pub mod store;
39pub mod sync;
40
41pub use conflict::{
42    ConflictResolution, ConflictStrategy, HighestConfidence, KeepLocal, LastWriteWins, MergeJson,
43};
44pub use error::{MirrorError, Result};
45pub use event::{Delta, DeltaOp, MirroredRecord, Provenance};
46pub use kernel::MirrorModule;
47pub use source::{PullResult, StaticSource, SyncSource};
48pub use store::MirrorStore;
49pub use sync::{SyncReport, Syncer};