systemprompt-runtime 0.6.0

Application runtime for systemprompt.io AI governance infrastructure. AppContext, lifecycle builder, extension registry, and module wiring for the MCP governance pipeline.
//! Typed error boundary for the runtime crate.
//!
//! All public APIs of `systemprompt-runtime` return [`RuntimeResult<T>`]
//! (i.e. `Result<T, RuntimeError>`). [`RuntimeError`] composes the typed
//! errors of upstream layers (config, database, events, files, users,
//! extensions) via `#[from]` so callers can pattern-match on the original
//! cause without losing fidelity.
//!
//! Calls into upstream crates that still return `anyhow::Result` (for
//! example schema/seed installation and database connectivity probes)
//! are stringified into the [`RuntimeError::Internal`] variant at the
//! call site so the lossy conversion is visible.

use systemprompt_analytics::AnalyticsError;
use systemprompt_config::{ConfigError as ProfileConfigError, ProfileBootstrapError};
use systemprompt_database::RepositoryError;
use systemprompt_extension::LoaderError;
use systemprompt_files::FilesError;
use systemprompt_models::errors::ConfigError as ModelConfigError;
use systemprompt_models::paths::PathError;
use systemprompt_users::UserError;
use thiserror::Error;

pub type RuntimeResult<T> = Result<T, RuntimeError>;

#[derive(Debug, Error)]
pub enum RuntimeError {
    #[error(transparent)]
    Profile(#[from] ProfileConfigError),

    #[error(transparent)]
    ProfileBootstrap(#[from] ProfileBootstrapError),

    #[error(transparent)]
    Config(#[from] ModelConfigError),

    #[error(transparent)]
    Paths(#[from] PathError),

    #[error(transparent)]
    Files(#[from] FilesError),

    #[error(transparent)]
    Users(#[from] UserError),

    #[error(transparent)]
    Repository(#[from] RepositoryError),

    #[error(transparent)]
    Analytics(#[from] AnalyticsError),

    #[error(transparent)]
    Loader(#[from] LoaderError),

    #[error("DATABASE_URL is empty")]
    EmptyDatabaseUrl,

    #[error("Database not found at '{path}'. Run setup first")]
    DatabaseNotFound { path: String },

    #[error("Database path '{path}' exists but is not a file")]
    DatabaseNotFile { path: String },

    #[error("internal: {0}")]
    Internal(String),
}