Skip to main content

SessionStore

Struct SessionStore 

Source
pub struct SessionStore { /* private fields */ }
Expand description

Session store for SRBN persistence

Implementations§

Source§

impl SessionStore

Source

pub fn new() -> Result<Self>

Create a new session store with default path

Source

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

Open a session store at the given path

Source

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

Open a session store in read-only mode for concurrent dashboard reads.

Uses AccessMode::ReadOnly so the dashboard can read alongside the agent’s write lock. Does not call init_schema() (a write op). The database file must already exist.

Source

pub fn database_path(&self) -> &Path

Absolute path of the database backing this handle.

Source

pub fn default_db_path() -> Result<PathBuf>

Get the default database path (~/.local/share/perspt/perspt.db or similar)

Source§

impl SessionStore

Source

pub fn put_psp9_artifact( &self, content_hash: &str, content: &[u8], media_type: &str, ) -> Result<()>

Source

pub fn get_psp9_artifact(&self, content_hash: &str) -> Result<Option<Vec<u8>>>

Source

pub fn record_psp9_checkpoint( &self, session_id: &str, covered_event_root: &str, checkpoint_json: &str, ) -> Result<()>

Source

pub fn latest_psp9_checkpoint(&self, session_id: &str) -> Result<Option<String>>

The newest checkpoint JSON for a session, if any.

Source

pub fn record_psp9_verdict(&self, row: &Psp9VerdictRow) -> Result<()>

Source

pub fn get_psp9_verdicts(&self, session_id: &str) -> Result<Vec<Psp9VerdictRow>>

Per-validator verdict history for one session, in insertion order.

Source

pub fn record_psp9_calibration_epoch( &self, row: &Psp9CalibrationEpochRow, ) -> Result<()>

Source

pub fn latest_psp9_calibration_epoch( &self, stratum: &str, ) -> Result<Option<Psp9CalibrationEpochRow>>

Return the newest immutable epoch for exactly one serialized stratum. A caller must never reuse an epoch across a changed stratum.

Source

pub fn psp9_calibration_samples( &self, epoch_id: &str, ) -> Result<Vec<(String, f64, Option<bool>, bool)>>

Source

pub fn record_psp9_calibration_sample( &self, epoch_id: &str, sample_id: &str, score: f64, unsafe_label: Option<bool>, audit_selected: bool, ) -> Result<()>

Source

pub fn label_psp9_calibration_sample( &self, sample_id: &str, is_unsafe: bool, ) -> Result<usize>

Ingest one delayed audit label. Returns how many rows were labeled (0 when the sample is unknown or already labeled — labels are single-assignment, matching the ledger’s write-once discipline).

Source

pub fn label_psp9_verdicts( &self, candidate_id: &str, is_unsafe: bool, ) -> Result<usize>

Single-assignment delayed label on every verdict row for a candidate — the same oracle labels calibration samples and validator verdicts in one pass (PSP-9 system 8).

Source

pub fn labeled_psp9_verdicts(&self) -> Result<Vec<Psp9VerdictRow>>

Labeled verdict rows across all sessions, for the independence estimator (matched strata are joined by candidate id downstream).

Source

pub fn pending_psp9_audit_samples( &self, limit: usize, ) -> Result<Vec<(String, String, f64)>>

Audit-selected samples still waiting for their delayed label.

Source

pub fn labeled_psp9_samples_for_stratum( &self, stratum: &str, ) -> Result<Vec<(f64, bool)>>

Every labeled sample across all epochs of one serialized stratum, for threshold recomputation. Unlabeled samples never count toward the conformal floor.

Source

pub fn all_psp9_calibration_epochs( &self, limit: usize, ) -> Result<Vec<Psp9CalibrationEpochRow>>

Newest-first calibration epochs across all strata.

Source

pub fn psp9_epoch_stratum(&self, epoch_id: &str) -> Result<Option<String>>

The stratum an epoch belongs to.

Source

pub fn record_psp9_event(&self, row: &Psp9LedgerRow) -> Result<()>

Append one PSP-9 ledger record durably.

Source

pub fn get_psp9_events(&self, session_id: &str) -> Result<Vec<Psp9LedgerRow>>

Load a session’s PSP-9 event stream in sequence order.

Source

pub fn initialize_authority_epoch( &self, session_id: &str, epoch: u64, ) -> Result<()>

Source

pub fn authority_epoch(&self, session_id: &str) -> Result<u64>

Source

pub fn with_authority_epoch<T>( &self, session_id: &str, expected_epoch: u64, operation: impl FnOnce() -> Result<T>, ) -> Result<T>

Execute one synchronous durable effect while holding the database’s authority-epoch write lock. Revocation uses the same row and therefore cannot commit between the epoch check and operation.

Source

pub fn revoke_authority(&self, session_id: &str) -> Result<u64>

Source

pub fn record_grant_policy( &self, session_id: &str, policy_id: &str, policy_json: &str, ) -> Result<()>

Source

pub fn get_grant_policy(&self, session_id: &str) -> Result<Option<String>>

The newest persisted grant-policy JSON for a session, if any.

Source

pub fn record_external_effect_intent( &self, session_id: &str, idempotency_key: &str, intent_hash: &str, intent_json: &str, ) -> Result<()>

R1/R5: durably single-assign an external-effect intent before the filesystem or network is touched. Redelivery with identical bytes is idempotent; key reuse with different content is rejected.

Source

pub fn complete_external_effect( &self, session_id: &str, idempotency_key: &str, result_json: &str, ) -> Result<()>

Source

pub fn completed_external_effects( &self, session_id: &str, ) -> Result<Vec<Psp9ExternalEffectRow>>

Completed promotion intents, newest first — the rollback surface.

Source

pub fn pending_external_effects( &self, session_id: &str, ) -> Result<Vec<Psp9ExternalEffectRow>>

Source§

impl SessionStore

Source

pub fn create_session(&self, session: &SessionRecord) -> Result<()>

Create a new session

Source

pub fn get_session(&self, session_id: &str) -> Result<Option<SessionRecord>>

Get session by ID

Source

pub fn get_session_dir(&self, session_id: &str) -> Result<PathBuf>

Get the directory for session artifacts (~/.local/share/perspt/sessions/<id>)

Source

pub fn create_session_dir(&self, session_id: &str) -> Result<PathBuf>

Ensure a session directory exists and return the path

Source

pub fn list_recent_sessions(&self, limit: usize) -> Result<Vec<SessionRecord>>

List recent sessions (newest first)

Source

pub fn list_sessions_paginated( &self, limit: usize, offset: usize, ) -> Result<Vec<SessionRecord>>

List sessions with pagination (most recent first).

Source

pub fn count_sessions(&self) -> Result<usize>

Count total number of sessions.

Source

pub fn update_session_status( &self, session_id: &str, status: &str, ) -> Result<()>

Update session status

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.

§

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
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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<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<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

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,