pub struct Db {
pub conn: Connection,
}Fields§
§conn: ConnectionImplementations§
Source§impl Db
impl Db
Sourcepub fn open_read_only(path: &Path) -> Result<Db, StoreError>
pub fn open_read_only(path: &Path) -> Result<Db, StoreError>
Read-only open for reporting over OTHER repos’ databases (stats --all):
no migration, no WAL side files, works on read-only caches, and never
touches a DB that a live agent session is writing.
pub fn open(path: &Path) -> Result<Db, StoreError>
pub fn insert_run(&self, r: &RunRecord) -> Result<(), StoreError>
Sourcepub fn get_run(&self, target: &str) -> Result<Option<RunRecord>, StoreError>
pub fn get_run(&self, target: &str) -> Result<Option<RunRecord>, StoreError>
Resolve a run by exact id, then by unique short-id prefix (newest wins).
Sourcepub fn count_prefix(&self, prefix: &str) -> Result<i64, StoreError>
pub fn count_prefix(&self, prefix: &str) -> Result<i64, StoreError>
How many runs share a short-id prefix (for ambiguity detection).
pub fn latest_run( &self, repo_root: &str, ) -> Result<Option<RunRecord>, StoreError>
Sourcepub fn find_comparable_prior(
&self,
repo_root: &str,
cwd: &str,
command_family: &str,
command_key: &str,
before_created_at: &str,
) -> Result<Option<RunRecord>, StoreError>
pub fn find_comparable_prior( &self, repo_root: &str, cwd: &str, command_family: &str, command_key: &str, before_created_at: &str, ) -> Result<Option<RunRecord>, StoreError>
The most recent comparable prior run (spec §12, hybrid decision #3):
matched on (repo_root, cwd, command_family, command_key). Git state is
NOT part of the match.
pub fn upsert_session_start(&self, s: &SessionRecord) -> Result<(), StoreError>
pub fn accumulate_session_tokens( &self, session_id: &str, raw: i64, emitted: i64, saved: i64, ) -> Result<(), StoreError>
pub fn mark_full_output_requested(&self, run_id: &str) -> Result<(), StoreError>
Sourcepub fn runs_before(
&self,
repo_root: &str,
cutoff: &str,
) -> Result<Vec<RunRecord>, StoreError>
pub fn runs_before( &self, repo_root: &str, cutoff: &str, ) -> Result<Vec<RunRecord>, StoreError>
Runs older than cutoff (RFC3339), for log-file cleanup.
Sourcepub fn delete_runs_before(
&self,
repo_root: &str,
cutoff: &str,
) -> Result<usize, StoreError>
pub fn delete_runs_before( &self, repo_root: &str, cutoff: &str, ) -> Result<usize, StoreError>
Delete run rows older than cutoff. Returns the number deleted.
Sourcepub fn aggregate_stats(
&self,
repo_root: Option<&str>,
) -> Result<StatsAgg, StoreError>
pub fn aggregate_stats( &self, repo_root: Option<&str>, ) -> Result<StatsAgg, StoreError>
Aggregate run stats; repo_root: None aggregates the whole database.
Sourcepub fn top_savings(
&self,
repo_root: Option<&str>,
limit: Option<usize>,
) -> Result<Vec<(String, i64)>, StoreError>
pub fn top_savings( &self, repo_root: Option<&str>, limit: Option<usize>, ) -> Result<Vec<(String, i64)>, StoreError>
Top-N (display, saved_tokens) grouped by command, most savings first.
Top saving commands; limit: None returns them all (SQLite LIMIT -1).
Sourcepub fn repo_roots(&self) -> Result<Vec<String>, StoreError>
pub fn repo_roots(&self) -> Result<Vec<String>, StoreError>
Distinct repo roots recorded in this database (normally one per cache).
pub fn session_count(&self, repo_root: &str) -> Result<i64, StoreError>
pub fn latest_activity( &self, repo_root: &str, ) -> Result<Option<String>, StoreError>
Source§impl Db
impl Db
Sourcepub fn end_session(
&self,
session_id: &str,
ended_at: &str,
) -> Result<(), StoreError>
pub fn end_session( &self, session_id: &str, ended_at: &str, ) -> Result<(), StoreError>
Mark a session ended (idempotent — only sets ended_at once).