pub struct SessionStore { /* private fields */ }Expand description
Session store for SRBN persistence
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn open_read_only(path: &Path) -> Result<Self>
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.
Sourcepub fn database_path(&self) -> &Path
pub fn database_path(&self) -> &Path
Absolute path of the database backing this handle.
Sourcepub fn default_db_path() -> Result<PathBuf>
pub fn default_db_path() -> Result<PathBuf>
Get the default database path (~/.local/share/perspt/perspt.db or similar)
Source§impl SessionStore
impl SessionStore
pub fn put_psp9_artifact( &self, content_hash: &str, content: &[u8], media_type: &str, ) -> Result<()>
pub fn get_psp9_artifact(&self, content_hash: &str) -> Result<Option<Vec<u8>>>
pub fn record_psp9_checkpoint( &self, session_id: &str, covered_event_root: &str, checkpoint_json: &str, ) -> Result<()>
Sourcepub fn latest_psp9_checkpoint(&self, session_id: &str) -> Result<Option<String>>
pub fn latest_psp9_checkpoint(&self, session_id: &str) -> Result<Option<String>>
The newest checkpoint JSON for a session, if any.
pub fn record_psp9_verdict(&self, row: &Psp9VerdictRow) -> Result<()>
Sourcepub fn get_psp9_verdicts(&self, session_id: &str) -> Result<Vec<Psp9VerdictRow>>
pub fn get_psp9_verdicts(&self, session_id: &str) -> Result<Vec<Psp9VerdictRow>>
Per-validator verdict history for one session, in insertion order.
pub fn record_psp9_calibration_epoch( &self, row: &Psp9CalibrationEpochRow, ) -> Result<()>
Sourcepub fn latest_psp9_calibration_epoch(
&self,
stratum: &str,
) -> Result<Option<Psp9CalibrationEpochRow>>
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.
pub fn psp9_calibration_samples( &self, epoch_id: &str, ) -> Result<Vec<(String, f64, Option<bool>, bool)>>
pub fn record_psp9_calibration_sample( &self, epoch_id: &str, sample_id: &str, score: f64, unsafe_label: Option<bool>, audit_selected: bool, ) -> Result<()>
Sourcepub fn label_psp9_calibration_sample(
&self,
sample_id: &str,
is_unsafe: bool,
) -> Result<usize>
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).
Sourcepub fn label_psp9_verdicts(
&self,
candidate_id: &str,
is_unsafe: bool,
) -> Result<usize>
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).
Sourcepub fn labeled_psp9_verdicts(&self) -> Result<Vec<Psp9VerdictRow>>
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).
Sourcepub fn pending_psp9_audit_samples(
&self,
limit: usize,
) -> Result<Vec<(String, String, f64)>>
pub fn pending_psp9_audit_samples( &self, limit: usize, ) -> Result<Vec<(String, String, f64)>>
Audit-selected samples still waiting for their delayed label.
Sourcepub fn labeled_psp9_samples_for_stratum(
&self,
stratum: &str,
) -> Result<Vec<(f64, bool)>>
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.
Sourcepub fn all_psp9_calibration_epochs(
&self,
limit: usize,
) -> Result<Vec<Psp9CalibrationEpochRow>>
pub fn all_psp9_calibration_epochs( &self, limit: usize, ) -> Result<Vec<Psp9CalibrationEpochRow>>
Newest-first calibration epochs across all strata.
Sourcepub fn psp9_epoch_stratum(&self, epoch_id: &str) -> Result<Option<String>>
pub fn psp9_epoch_stratum(&self, epoch_id: &str) -> Result<Option<String>>
The stratum an epoch belongs to.
Sourcepub fn record_psp9_event(&self, row: &Psp9LedgerRow) -> Result<()>
pub fn record_psp9_event(&self, row: &Psp9LedgerRow) -> Result<()>
Append one PSP-9 ledger record durably.
Sourcepub fn get_psp9_events(&self, session_id: &str) -> Result<Vec<Psp9LedgerRow>>
pub fn get_psp9_events(&self, session_id: &str) -> Result<Vec<Psp9LedgerRow>>
Load a session’s PSP-9 event stream in sequence order.
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.
pub fn record_grant_policy( &self, session_id: &str, policy_id: &str, policy_json: &str, ) -> Result<()>
Sourcepub fn get_grant_policy(&self, session_id: &str) -> Result<Option<String>>
pub fn get_grant_policy(&self, session_id: &str) -> Result<Option<String>>
The newest persisted grant-policy JSON for a session, if any.
Sourcepub fn record_external_effect_intent(
&self,
session_id: &str,
idempotency_key: &str,
intent_hash: &str,
intent_json: &str,
) -> Result<()>
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.
pub fn complete_external_effect( &self, session_id: &str, idempotency_key: &str, result_json: &str, ) -> Result<()>
Sourcepub fn completed_external_effects(
&self,
session_id: &str,
) -> Result<Vec<Psp9ExternalEffectRow>>
pub fn completed_external_effects( &self, session_id: &str, ) -> Result<Vec<Psp9ExternalEffectRow>>
Completed promotion intents, newest first — the rollback surface.
pub fn pending_external_effects( &self, session_id: &str, ) -> Result<Vec<Psp9ExternalEffectRow>>
Source§impl SessionStore
impl SessionStore
Sourcepub fn create_session(&self, session: &SessionRecord) -> Result<()>
pub fn create_session(&self, session: &SessionRecord) -> Result<()>
Create a new session
Sourcepub fn get_session(&self, session_id: &str) -> Result<Option<SessionRecord>>
pub fn get_session(&self, session_id: &str) -> Result<Option<SessionRecord>>
Get session by ID
Sourcepub fn get_session_dir(&self, session_id: &str) -> Result<PathBuf>
pub fn get_session_dir(&self, session_id: &str) -> Result<PathBuf>
Get the directory for session artifacts (~/.local/share/perspt/sessions/<id>)
Sourcepub fn create_session_dir(&self, session_id: &str) -> Result<PathBuf>
pub fn create_session_dir(&self, session_id: &str) -> Result<PathBuf>
Ensure a session directory exists and return the path
Sourcepub fn list_recent_sessions(&self, limit: usize) -> Result<Vec<SessionRecord>>
pub fn list_recent_sessions(&self, limit: usize) -> Result<Vec<SessionRecord>>
List recent sessions (newest first)
Sourcepub fn list_sessions_paginated(
&self,
limit: usize,
offset: usize,
) -> Result<Vec<SessionRecord>>
pub fn list_sessions_paginated( &self, limit: usize, offset: usize, ) -> Result<Vec<SessionRecord>>
List sessions with pagination (most recent first).
Sourcepub fn count_sessions(&self) -> Result<usize>
pub fn count_sessions(&self) -> Result<usize>
Count total number of sessions.
Auto Trait Implementations§
impl !Freeze for SessionStore
impl RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl UnwindSafe for SessionStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.