#![allow(
    // Pedantic + nursery lints kept as `warn` in Cargo.toml for guidance,
    // but the pre-commit `cargo clippy -- -D warnings` would promote
    // them to errors. Inherited code is exempt; new code should still avoid
    // these patterns (run `cargo clippy` to see them surfaced as warnings).
    clippy::missing_errors_doc,
    clippy::missing_panics_doc,
    clippy::option_if_let_else,
    clippy::redundant_closure_for_method_calls,
    clippy::similar_names,
    clippy::unreadable_literal,
    clippy::default_trait_access,
)]

pub mod cohort;
pub mod db;
pub mod entities;
pub mod governance;
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 `TIDALDB_BUILD_HASH` environment variable.
///
/// Falls back to `"dev"` if `TIDALDB_BUILD_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;
#[cfg(feature = "metrics")]
pub use db::http::MetricsHandle;
pub use db::{
    Config, ConfigError, NodeConfig, Paths, StorageMode, TidalDb, TidalDbBuilder,
    backup::BackupInfo,
    config::NodeRole,
    export::{ExportFormat, ExportRequest, ExportedSignal, UserSessionSummary},
    metrics::MetricsState,
};
pub use governance::{
    CapabilityToken, CommunityId, ContributionProvenance, GovernancePolicy, GovernanceRegistry,
    LeaveMode, MembershipState, PurgeReceipt, RemoveScope, ScopeClass, ScopePermission,
    ShareIntent, ShareMode, SharePolicy, SignalProvenance, SignalScope, UserId, WeightingBounds,
};
pub use load::DegradationLevel;
pub use schema::{AgentPolicy, TidalError, error::ErrorContext};
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>;
