engram_storage/
routing_log.rs1use rusqlite::params;
2
3use crate::database::Database;
4use crate::error::StorageError;
5
6pub struct RoutingLogEntry<'a> {
7 pub query_id: &'a str,
8 pub mode: &'a str,
9 pub search_strategy: &'a str,
10 pub llm_selection: &'a str,
11 pub contextualization: &'a str,
12 pub proactivity: &'a str,
13 pub top_k: usize,
14 pub shadow_rewards_json: Option<&'a str>,
15 pub created_at: &'a str,
16}
17
18impl Database {
19 pub fn log_routing_decision(&self, entry: &RoutingLogEntry<'_>) -> Result<(), StorageError> {
20 self.connection().execute(
21 "INSERT INTO routing_log \
22 (query_id, mode, search_strategy, llm_selection, contextualization, proactivity, top_k, shadow_rewards, created_at) \
23 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
24 params![
25 entry.query_id,
26 entry.mode,
27 entry.search_strategy,
28 entry.llm_selection,
29 entry.contextualization,
30 entry.proactivity,
31 entry.top_k as i64,
32 entry.shadow_rewards_json,
33 entry.created_at,
34 ],
35 )?;
36 Ok(())
37 }
38}