Skip to main content

SQLiteStore

Struct SQLiteStore 

Source
pub struct SQLiteStore { /* private fields */ }

Implementations§

Source§

impl SQLiteStore

Source

pub fn migrate_legacy(path: impl AsRef<Path>) -> Result<Self>

Explicitly migrate an existing schema 0/1/2 database in one transaction. Ordinary opens and all read-only access remain non-migrating. Back up an existing recording before requesting migration. Unknown versions and malformed nodes are rejected without committing schema/data changes.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn open_read_only(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn open_with_options( path: impl AsRef<Path>, read_only: bool, intern_threshold: Option<usize>, ) -> Result<Self>

None disables interning. Existing legacy schemas are refused, never repaired.

Source

pub fn is_read_only(&self) -> bool

Source

pub fn reserve( &mut self, reservation_id: &str, budgets: &[BudgetReservation], windows: &[WindowReservation], lease_seconds: f64, ) -> Result<ReservationCheck>

Explicit reserve operation, serialized across independent SQLite connections. Direct callers must settle or release accepted reservations and renew leases while work is in flight. RecordingStore hooks expose these operations to Runtime.

Source

pub fn reserve_decimal_text( &mut self, reservation_id: &str, budgets: &[TextBudgetReservation], windows: &[TextWindowReservation], lease_seconds: f64, ) -> Result<ReservationCheck>

Preserve Python Decimal text in SQLite ledger rows. SQLite’s schema-v3 retry semantics are unchanged (active duplicate IDs are refused).

Source

pub fn settle( &mut self, reservation_id: &str, charges: &BTreeMap<String, Decimal>, ) -> Result<()>

Settle each reserved budget/window once, then remove its reservation rows. Repeating settlement after success is idempotent, matching Python.

Source

pub fn settle_decimal_text( &mut self, reservation_id: &str, charges: &BTreeMap<String, String>, ) -> Result<()>

Settle using the original Python Decimal scale/exponent for ledger text.

Source

pub fn release(&mut self, reservation_id: &str) -> Result<()>

Source

pub fn renew( &mut self, reservation_id: &str, lease_seconds: f64, ) -> Result<bool>

Trait Implementations§

Source§

impl RecordingStore for SQLiteStore

Source§

fn ancestry_snapshot(&self, id: &str) -> Result<Option<Vec<Node>>>

Return a detached, consistent read of the requested node followed by all ancestors, ending at a root. All payload blobs must share that snapshot. None means the backend cannot provide a snapshot; runtime verification then retains its fail-closed behavior under sustained concurrent changes.
Source§

fn subtree_snapshot(&self, root: &str) -> Result<Option<Vec<Node>>>

Return a detached, consistent read of the complete subtree rooted here, with the requested root first and each parent preceding its children. The root’s external ancestry must also be verified in the same snapshot. Snapshot reads must not leave a transaction open after success or failure.
Source§

fn cache_revision(&self) -> Option<StoreRevision>

A token valid only on this store instance. Returning Some promises that every committed mutation changes a component and that reads observe the current token. Local writes preserve settled identity/result bytes; other changes, including external SQL and triggers, must change external. A single-node write must not modify other cached nodes; such side effects require changing external or returning None instead. Runtimes recheck tokens after scans and discard caches on any change.
Source§

fn supports_reservations(&self) -> bool

Source§

fn reserve_budget( &mut self, id: &str, budgets: &[BudgetReservation], windows: &[WindowReservation], lease_seconds: f64, ) -> Result<Option<ReservationCheck>>

None means this backend has no shared-budget arbiter.
Source§

fn settle_budget( &mut self, id: &str, charges: &BTreeMap<String, Decimal>, ) -> Result<()>

Source§

fn release_budget(&mut self, id: &str) -> Result<()>

Source§

fn lease_renewer(&self) -> Option<LeaseRenewer>

An independent connection-safe heartbeat, callable while a handler executes.
Source§

fn finalize(&mut self, node: Node) -> Result<()>

Source§

fn stage_pending(&mut self, node: Node) -> Result<()>

Stage a live call before dispatch. Append-only backends may keep this transient and publish a single completed record during finalization.
Source§

fn revision(&self) -> Option<u64>

Revision covering every store mutation, or None for externally writable stores.
Source§

fn trusted_immutable_identity(&self) -> bool

Existing settled identity/result bytes cannot change through this backend.
Source§

impl Store for SQLiteStore

Source§

fn import_nodes(&mut self, nodes: Vec<Node>) -> Result<(usize, usize)>

Import collision checks and writes share one transaction on native stores.
Source§

fn merge_nodes(&mut self, nodes: Vec<Node>, replay: bool) -> Result<MergeReport>

Merge destination reads and writes share one transaction on SQLite.
Source§

fn put(&mut self, node: Node) -> Result<()>

Source§

fn get(&self, id: &str) -> Result<Node>

Source§

fn exists(&self, id: &str) -> bool

Source§

fn try_exists(&self, id: &str) -> Result<bool>

Fallible existence query. Runtime dispatch must use this method so a remote connection failure cannot be mistaken for a missing recording.
Source§

fn children(&self, id: &str) -> Result<Vec<String>>

Source§

fn update_meta(&mut self, id: &str, patch: Value) -> Result<()>

Source§

fn roots(&self) -> Result<Vec<String>>

Source§

fn apply_batch( &mut self, nodes: Vec<Node>, patches: Vec<(String, Value)>, ) -> Result<()>

Apply a prevalidated batch. Backends may override to provide atomicity.
Source§

fn drop_nodes(&mut self, ids: &BTreeSet<String>) -> Result<()>

Source§

fn compact(&mut self) -> Result<usize>

Source§

fn operation_log(&self) -> Result<Vec<u8>>

Snapshot compatible append-only log bytes, when the backend exposes one.
Source§

fn walk(&self, root: &str) -> Result<Vec<Node>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.