pub mod iceberg;
pub mod iceberg_schema;
pub mod dep_graph;
pub mod funnel;
pub mod release_events;
pub mod test_results;
pub mod surface_coverage;
pub mod viz_actions;
pub mod agent_model_runs;
pub mod codegen_judge;
pub mod blob_store;
pub mod access_scan;
pub mod warehouse_access;
pub mod generator;
use std::path::Path;
use anyhow::Result;
use uuid::Uuid;
use crate::bench::BenchRun;
use crate::config::Storage;
pub trait Warehouse: Send + Sync {
fn append_bench_run(&self, repo: &str, run: &BenchRun) -> Result<Uuid>;
fn query_bench_runs(&self, filter: &BenchFilter) -> Result<Vec<BenchRun>>;
}
#[derive(Debug, Default, Clone)]
pub struct BenchFilter {
pub repo: Option<String>,
pub machine: Option<String>,
pub limit: Option<usize>,
}
impl BenchFilter {
pub fn for_repo(repo: impl Into<String>) -> Self {
Self { repo: Some(repo.into()), machine: None, limit: None }
}
}
pub fn open(storage: &Storage, workspace_root: &Path) -> Result<Box<dyn Warehouse>> {
match storage.kind.as_str() {
"" | "local" | "iceberg" => {
let root = warehouse_root(storage, workspace_root);
Ok(Box::new(iceberg::IcebergWarehouse::open(&root)?))
}
"remote" => anyhow::bail!("remote warehouse not yet implemented (Phase 5)"),
other => anyhow::bail!("unknown storage.kind: {other}"),
}
}
pub fn open_read_only(storage: &Storage, workspace_root: &Path) -> Result<Box<dyn Warehouse>> {
match storage.kind.as_str() {
"" | "local" | "iceberg" => {
let root = warehouse_root(storage, workspace_root);
Ok(Box::new(iceberg::IcebergWarehouse::open_read_only(&root)?))
}
"remote" => anyhow::bail!("remote warehouse not yet implemented (Phase 5)"),
other => anyhow::bail!("unknown storage.kind: {other}"),
}
}
fn warehouse_root(storage: &Storage, workspace_root: &Path) -> std::path::PathBuf {
if storage.local_path.is_empty() {
crate::config::warehouse_default_root()
} else {
workspace_root.join(&storage.local_path).join("warehouse")
}
}