|
| 1 | +//! Behavioural conformance for `MemoryProvider` drivers. |
| 2 | +//! |
| 3 | +//! TinyMemory's premise is that an engine can be swapped without the host |
| 4 | +//! learning anything new. [`audit_provider`](tinymemory_api::provider::audit_provider) |
| 5 | +//! checks that a driver's advertised capabilities match its reachable |
| 6 | +//! accessors, which proves the *shape* is honest. Nothing checked that two |
| 7 | +//! drivers answer the same question the same way — and that is the claim the |
| 8 | +//! premise actually rests on. |
| 9 | +//! |
| 10 | +//! This crate is that check. Hand [`assert_provider`] any bound driver and it |
| 11 | +//! drives the contract: the mandatory three families, upsert semantics on |
| 12 | +//! `(namespace, key)`, namespace isolation, provenance preservation, recall |
| 13 | +//! limits, export pagination, and import round-tripping. |
| 14 | +//! |
| 15 | +//! ```no_run |
| 16 | +//! use std::sync::Arc; |
| 17 | +//! use tinymemory_conformance::{assert_provider, InMemoryProvider}; |
| 18 | +//! |
| 19 | +//! # async fn run() { |
| 20 | +//! assert_provider(Arc::new(InMemoryProvider::new())).await; |
| 21 | +//! # } |
| 22 | +//! ``` |
| 23 | +//! |
| 24 | +//! # What it deliberately does not depend on |
| 25 | +//! |
| 26 | +//! Only `tinymemory-api`. A conformance suite that pulled in an engine could |
| 27 | +//! not prove interchangeability, because it would already have chosen one — and |
| 28 | +//! reaching `tinymemory-core` would drag in a bundled SQLite and the embedded |
| 29 | +//! engine besides (issue #18 §D). |
| 30 | +//! |
| 31 | +//! # Provenance is the sharp one |
| 32 | +//! |
| 33 | +//! [`assert_taint_is_preserved`] is not a formality. A driver that reads back |
| 34 | +//! `Internal` for content stored as `ExternalSync` has laundered external |
| 35 | +//! content into internal-trust content, and every policy gate keyed on taint is |
| 36 | +//! then silently wrong. That failure is invisible until something acts on it. |
| 37 | +
|
| 38 | +#![forbid(unsafe_code)] |
| 39 | +#![warn(missing_docs)] |
| 40 | + |
| 41 | +pub mod reference; |
| 42 | +pub mod suite; |
| 43 | + |
| 44 | +pub use reference::{InMemoryProvider, REFERENCE_DRIVER_ID}; |
| 45 | +pub use suite::{ |
| 46 | + assert_awkward_content_round_trips, assert_capability_audit, assert_export_cursor_terminates, |
| 47 | + assert_export_import_round_trip, assert_forget_is_idempotent, assert_list_filters_narrow, |
| 48 | + assert_namespaces_are_isolated, assert_provider, assert_recall_respects_limit_and_namespace, |
| 49 | + assert_store_get_round_trip, assert_taint_is_preserved, |
| 50 | + assert_upsert_replaces_rather_than_duplicates, |
| 51 | +}; |
0 commit comments