pub struct Storage {
pub db_path: PathBuf,
pub content_dim: usize,
pub trigger_dim: usize,
/* private fields */
}Fields§
§db_path: PathBuf§content_dim: usize§trigger_dim: usizeImplementations§
Source§impl Storage
impl Storage
pub fn open( db_path: impl AsRef<Path>, content_dim: usize, trigger_dim: usize, ) -> Result<Self>
pub fn open_readonly(db_path: impl AsRef<Path>) -> Result<Self>
pub fn begin_immediate(&self) -> Result<()>
pub fn commit(&self) -> Result<()>
pub fn rollback(&self) -> Result<()>
pub fn get_meta(&self, key: &str) -> Result<Option<String>>
pub fn set_meta(&self, key: &str, value: &str) -> Result<()>
pub fn get_meta_or(&self, key: &str, default: &str) -> String
pub fn insert_chunk(&self, c: &ChunkRow) -> Result<()>
pub fn insert_vec_content(&self, chunk_id: &str, emb: &[u8]) -> Result<()>
pub fn insert_vec_trigger(&self, chunk_id: &str, emb: &[u8]) -> Result<()>
pub fn get_chunk(&self, id: &str) -> Result<Option<Value>>
pub fn update_chunk_state( &self, id: &str, state: &str, reason: Option<&str>, now: &str, ) -> Result<()>
pub fn update_chunk_confidence( &self, id: &str, conf: f64, reason: Option<&str>, now: &str, ) -> Result<()>
pub fn update_chunk_last_used(&self, id: &str, now: &str) -> Result<()>
pub fn get_chunk_by_hash(&self, hash: &str) -> Result<Option<Value>>
pub fn search_vec_content( &self, query: &[f32], limit: usize, ) -> Result<Vec<(String, f32)>>
pub fn search_vec_trigger( &self, query: &[f32], limit: usize, ) -> Result<Vec<(String, f32)>>
Sourcepub fn get_chunks_by_ids(&self, ids: &[&str]) -> Result<HashMap<String, Value>>
pub fn get_chunks_by_ids(&self, ids: &[&str]) -> Result<HashMap<String, Value>>
Fetch multiple chunks by id in one query; returns a map of id → chunk JSON.
pub fn is_hash_invalidated(&self, hash: &str) -> Result<bool>
pub fn insert_invalidated_hash( &self, hash: &str, reason: Option<&str>, ts: &str, ) -> Result<()>
pub fn insert_usage_trace( &self, trace_id: &str, chunk_id: Option<&str>, event: &str, strength: f64, similarity: Option<f64>, refine_mode: Option<&str>, tokens: Option<i64>, rank: Option<i64>, attribution: Option<&str>, source: &str, ts: &str, ) -> Result<usize>
pub fn replace_used_trace( &self, trace_id: &str, used_ids: &[String], strength: f64, attribution: &str, source: &str, ts: &str, ) -> Result<()>
pub fn merge_used_trace( &self, trace_id: &str, used_ids: &[String], strength: f64, attribution: &str, source: &str, ts: &str, ) -> Result<()>
pub fn refresh_chunk_last_used(&self, chunk_id: &str, now: &str) -> Result<()>
pub fn get_outcome_for_trace(&self, trace_id: &str) -> Result<Option<String>>
pub fn purge_usage_trace(&self, before_ts: &str) -> Result<usize>
pub fn upsert_episodic_log(&self, log: &EpisodicLogRow) -> Result<()>
pub fn get_episodic_log(&self, trace_id: &str) -> Result<Option<Value>>
pub fn update_episodic_log_state( &self, trace_id: &str, state: &str, note: Option<&str>, outcome: Option<&str>, ) -> Result<()>
Sourcepub fn patch_episodic_log_content(
&self,
trace_id: &str,
query: Option<&str>,
output: Option<&str>,
output_summary: Option<&str>,
nomination: Option<&str>,
priority: i64,
) -> Result<()>
pub fn patch_episodic_log_content( &self, trace_id: &str, query: Option<&str>, output: Option<&str>, output_summary: Option<&str>, nomination: Option<&str>, priority: i64, ) -> Result<()>
Patch content fields on an existing episodic_log row (補写: output_summary, nomination, etc.)
pub fn update_trace_lifecycle( &self, trace_id: &str, task_state: &str, completed_at: Option<&str>, usage_state: Option<&str>, used_ids: Option<&str>, used_attribution: Option<&str>, used_complete: Option<bool>, ) -> Result<()>
pub fn upsert_confidence_evidence( &self, id: &str, trace_id: Option<&str>, chunk_id: &str, kind: &str, target: f64, alpha: f64, reason: &str, context_key: Option<&str>, ts: &str, ) -> Result<()>
pub fn delete_trace_confidence_evidence( &self, trace_id: &str, kinds: &[&str], ) -> Result<()>
pub fn delete_chunk_trace_confidence_evidence( &self, trace_id: &str, chunk_id: &str, kind: &str, ) -> Result<()>
pub fn confidence_evidence_for_chunk( &self, chunk_id: &str, ) -> Result<Vec<Value>>
pub fn insert_feedback_event( &self, id: &str, trace_id: &str, chunk_id: &str, signal: &str, strength: f64, source: &str, actor: Option<&str>, reason: Option<&str>, context_key: Option<&str>, ts: &str, ) -> Result<usize>
pub fn delete_feedback_event( &self, trace_id: &str, chunk_id: &str, signal: &str, ) -> Result<usize>
pub fn update_chunk_last_decayed_at(&self, id: &str, now: &str) -> Result<()>
pub fn update_context_stat( &self, chunk_id: &str, context_key: &str, success: i64, failure: i64, positive: i64, negative: i64, now: &str, ) -> Result<()>
pub fn context_score(&self, chunk_id: &str, context_key: &str) -> Result<f64>
pub fn upsert_governance_proposal( &self, id: &str, chunk_id: &str, proposal_type: &str, reason: &str, evidence_count: i64, evidence_score: f64, actor_count: i64, now: &str, ) -> Result<()>
pub fn request_evolve(&self, id: &str, reason: &str, now: &str) -> Result<()>
pub fn claim_evolve_request( &self, now: &str, stale_before: &str, ) -> Result<Option<String>>
pub fn finish_evolve_request( &self, id: &str, state: &str, note: Option<&str>, now: &str, ) -> Result<()>
pub fn finish_covered_evolve_requests( &self, requested_before: &str, now: &str, ) -> Result<()>
Sourcepub fn update_episodic_log_state_by_id(
&self,
id: &str,
state: &str,
note: Option<&str>,
outcome: Option<&str>,
) -> Result<()>
pub fn update_episodic_log_state_by_id( &self, id: &str, state: &str, note: Option<&str>, outcome: Option<&str>, ) -> Result<()>
Update by primary-key id (used after distill where we have the row id, not trace_id).
pub fn finish_distill_log( &self, id: &str, state: &str, note: Option<&str>, prompt_tokens: i64, completion_tokens: i64, accounted_at: &str, ) -> Result<()>
Sourcepub fn claim_distill_batch(
&self,
run_id: &str,
limit: usize,
locked_at: &str,
) -> Result<Vec<Value>>
pub fn claim_distill_batch( &self, run_id: &str, limit: usize, locked_at: &str, ) -> Result<Vec<Value>>
Claim a batch of ‘new’ logs for distillation: mark them ‘screening’ atomically. Returns the claimed rows (with distill_run_id set to run_id).
pub fn query_episodic_logs_open(&self, limit: usize) -> Result<Vec<Value>>
pub fn query_chunks(&self, sql: &str) -> Result<Vec<Value>>
pub fn query_chunks_params<P: Params>( &self, sql: &str, p: P, ) -> Result<Vec<Value>>
pub fn get_deps( &self, chunk_id: &str, ) -> Result<Vec<(String, String, Option<String>)>>
pub fn get_reverse_deps(&self, chunk_id: &str) -> Result<Vec<String>>
pub fn insert_dep( &self, src: &str, dst: &str, kind: &str, dst_lib: Option<&str>, ) -> Result<()>
pub fn upsert_chunk_success_trace( &self, chunk_id: &str, trace_id: &str, ts: &str, ) -> Result<()>
pub fn lib_id(&self) -> Result<String>
pub fn execute(&self, sql: &str) -> Result<()>
Auto Trait Implementations§
impl !Freeze for Storage
impl !RefUnwindSafe for Storage
impl !Sync for Storage
impl !UnwindSafe for Storage
impl Send for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
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
Mutably borrows from an owned value. Read more