pub mod cohort;
pub mod db;
pub mod entities;
pub mod load;
pub mod query;
pub mod ranking;
pub mod replication;
pub mod schema;
pub mod session;
pub mod signals;
pub mod storage;
pub mod text;
pub mod wal;

/// Build hash compiled in from the `GIT_HASH` environment variable.
///
/// Falls back to `"dev"` if `GIT_HASH` is unset or `build.rs` is not invoked.
///
/// # Examples
///
/// ```
/// let hash = tidaldb::BUILD_HASH;
/// assert!(!hash.is_empty(), "build hash must not be empty");
/// ```
pub const BUILD_HASH: &str = match option_env!("TIDALDB_BUILD_HASH") {
    Some(v) => v,
    None => "dev",
};

#[cfg(any(test, feature = "test-utils"))]
pub mod testing;

#[cfg(any(test, feature = "test-utils"))]
pub use db::TempTidalHome;
pub use db::backup::BackupInfo;
pub use db::config::NodeRole;
pub use db::export::{ExportFormat, ExportRequest, ExportedSignal, UserSessionSummary};
#[cfg(feature = "metrics")]
pub use db::http::MetricsHandle;
pub use db::metrics::MetricsState;
pub use db::{Config, ConfigError, NodeConfig, Paths, StorageMode, TidalDb, TidalDbBuilder};
pub use load::DegradationLevel;
pub use schema::error::ErrorContext;
pub use schema::{AgentPolicy, TidalError};
pub use session::{
    AgentId, AuditEntry, SavedSearchInfo, SessionContext, SessionHandle, SessionId, SessionInfo,
    SessionSnapshot, SessionSummary, SignalSnapEntry,
};

/// Crate-wide result type. All public API methods return `Result<T, TidalError>`.
///
/// # Examples
///
/// ```
/// fn my_op() -> tidaldb::Result<()> {
///     Ok(())
/// }
/// assert!(my_op().is_ok());
/// ```
pub type Result<T> = std::result::Result<T, TidalError>;
