use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextChunkRecord {
pub content_hash: String,
pub source: String,
pub token_cost: usize,
pub turn_provided: u64,
}
impl ContextChunkRecord {
pub fn new(
content: &str,
source: impl Into<String>,
token_cost: usize,
turn_provided: u64,
) -> Self {
use std::hash::{Hash, Hasher};
let mut hasher = std::collections::hash_map::DefaultHasher::new();
content.hash(&mut hasher);
Self {
content_hash: format!("{:016x}", hasher.finish()),
source: source.into(),
token_cost,
turn_provided,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Outcome {
Success,
Failure,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OutcomeSignal {
pub session_id: String,
pub outcome: Outcome,
pub evidence: String,
}
pub fn record_chunk(_session_id: &str, _chunk: ContextChunkRecord) -> Result<(), String> {
Ok(())
}
pub fn chunks_for_session(_session_id: &str) -> Vec<ContextChunkRecord> {
Vec::new()
}
pub fn record_outcome(_task_id: &str, _signal: OutcomeSignal) -> Result<(), String> {
Ok(())
}
pub fn suggest_removals() -> Vec<String> {
Vec::new()
}
pub fn record_proxy_context<R>(
_session_id: &str,
_request: &R,
_turn_provided: u64,
) -> Result<(), String> {
Ok(())
}
pub struct CausalAttributor;
impl CausalAttributor {
pub fn default_path() -> Result<PathBuf, String> {
let dir = dirs::data_local_dir()
.unwrap_or_else(|| PathBuf::from("/tmp"))
.join("lean-ctx");
Ok(dir.join("causal_attribution.jsonl"))
}
}