Skip to main content

SqliteRunStore

Struct SqliteRunStore 

pub struct SqliteRunStore { /* private fields */ }
Expand description

Durable run store. Selected by build_run_store when persist_runs = true with the default "sqlite" backend.

Implementations§

Source§

impl SqliteRunStore

Source

pub fn open(path: &Path) -> Result<Self, StoreError>

Open (creating if absent) a database at path.

Source

pub fn open_in_memory() -> Result<Self, StoreError>

In-memory database (tests + the no-durability fallback).

Trait Implementations§

Source§

impl SopRunStore for SqliteRunStore

Source§

fn save_run(&self, run: &PersistedRun) -> Result<(), StoreError>

Persist-before-mutate. Revision-guarded: a strictly-older revision is rejected as StaleRevision; an equal revision is accepted only as a byte-identical idempotent retry, else RevisionConflict; a newer revision wins.
Source§

fn save_run_with_pending_capacity( &self, run: &PersistedRun, max_pending: usize, ) -> Result<bool, StoreError>

Persist a parked approval/checkpoint run only if this SOP still has room in its pending pool. Returns Ok(false) without saving when the pool is full. Store implementations should make the count and save one atomic critical section; the default preserves compatibility for test wrappers.
Source§

fn save_run_with_event( &self, run: &PersistedRun, ev: &SopEventRecord, ) -> Result<u64, StoreError>

Persist an active run transition and append its audit event as one store outcome. Implementations must make both writes visible together or neither visible at all; callers use this for approval gate resolution so a durable gate_resolved row cannot exist without the run transition it authorizes.
Source§

fn finish_run( &self, run_id: &str, terminal: &PersistedRun, ) -> Result<(), StoreError>

Move a run to terminal state (kept as a terminal record, not deleted) and release any live claim. Revision-guarded exactly like save_run, so a stale or divergent terminal write cannot clobber newer state or release a live claim.
Source§

fn finish_run_with_event( &self, run_id: &str, terminal: &PersistedRun, ev: &SopEventRecord, ) -> Result<u64, StoreError>

Move a run to terminal state and append its audit event as one store outcome. Claim release is part of the terminal transition and must be in the same atomic boundary as the audit append.
Source§

fn load_active_runs(&self) -> Result<Vec<PersistedRun>, StoreError>

Boot-rehydrate source: every non-terminal run (latest revision per id).
Source§

fn load_terminal_runs( &self, limit: usize, ) -> Result<Vec<PersistedRun>, StoreError>

Boot-rehydrate source for the display retention window: terminal runs, newest-first by started_at, truncated to limit (0 = unbounded). The engine seeds finished_runs from this so completed/failed/cancelled runs survive a restart in the Runs surface, matching max_finished_runs.
Source§

fn load_run(&self, run_id: &str) -> Result<Option<PersistedRun>, StoreError>

Single run by id (latest revision), terminal or not.
Source§

fn last_terminal_completed_at( &self, sop_name: &str, ) -> Result<Option<String>, StoreError>

completed_at of the most recently successful terminal run for sop_name, or None if that SOP has no completed run with a recorded completion. Drives the cooldown check off the shared store so every engine holder observes the same success marker (not just the engine that ran the SOP).
Source§

fn try_claim_run( &self, run_id: &str, sop_name: &str, per_sop_cap: usize, global_cap: usize, ) -> Result<Option<ClaimToken>, StoreError>

Source§

fn renew_claim_for_restore( &self, run_id: &str, sop_name: &str, ) -> Result<ClaimToken, StoreError>

Source§

fn mark_claim_retained_after_terminal_rollback( &self, run_id: &str, ) -> Result<(), StoreError>

Mark an existing live claim as intentionally retained while a failed terminal checkpoint decision is retried. No-op if the claim is already gone; the caller is already failing closed on the original transition.
Source§

fn has_retained_terminal_rollback_claim( &self, run_id: &str, ) -> Result<bool, StoreError>

Whether the live claim for run_id is an intentional terminal-rollback retention marker rather than a stale parked claim from old behavior.
Source§

fn claim_counts(&self, sop_name: &str) -> Result<(usize, usize), StoreError>

Live claim counts as (for_sop, total), used by read-only admission checks so status surfaces observe the same concurrency source as CAS.
Source§

fn heartbeat_claim(&self, token: &ClaimToken) -> Result<(), StoreError>

Renew a claim’s lease (tick liveness). No-op if the claim is gone.
Source§

fn release_claim(&self, token: &ClaimToken) -> Result<(), StoreError>

Release a claim (finish/cancel), freeing the slot for admission.
Source§

fn expired_claims(&self, now_iso: &str) -> Result<Vec<ClaimToken>, StoreError>

Reaper source: claims whose lease expired at/<= now_iso.
Source§

fn append_event(&self, ev: &SopEventRecord) -> Result<u64, StoreError>

Append-only, monotonic-seq, never-overwrite. Returns the assigned seq.
Source§

fn list_events(&self, run_id: &str) -> Result<Vec<SopEventRecord>, StoreError>

Ordered event history for a run.
Source§

fn save_proposal(&self, p: &ProposalRecord) -> Result<(), StoreError>

Source§

fn load_proposal(&self, id: &str) -> Result<Option<ProposalRecord>, StoreError>

Source§

fn list_proposals( &self, status: Option<ProposalStatus>, ) -> Result<Vec<ProposalRecord>, StoreError>

Source§

fn prune(&self, policy: &RetentionPolicy) -> Result<usize, StoreError>

Drop terminal runs beyond the retention policy. Returns the count dropped.
Source§

fn health_check(&self) -> bool

Source§

fn backend(&self) -> &'static str

Backend name (for logs + the “never a silent no-op” guard).

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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

§

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

§

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