systemprompt-config 0.7.0

Profile-based configuration for systemprompt.io AI governance infrastructure. Bootstraps profiles, secrets, and credentials with zero environment-variable fallback.
Documentation
//! Gateway catalog resolution for profiles that reference an external
//! catalog YAML via `gateway.catalog_path`.

use std::path::Path;

use systemprompt_models::profile::{
    GatewayCatalog, GatewayConfig, GatewayProfileError, GatewayResult,
};

pub fn resolve_catalog(gateway: &mut GatewayConfig, profile_dir: &Path) -> GatewayResult<()> {
    let Some(rel) = gateway.catalog_path.as_ref() else {
        return Ok(());
    };
    let absolute = if rel.is_absolute() {
        rel.clone()
    } else {
        profile_dir.join(rel)
    };
    let content =
        std::fs::read_to_string(&absolute).map_err(|source| GatewayProfileError::CatalogRead {
            path: absolute.clone(),
            source,
        })?;
    let catalog: GatewayCatalog =
        serde_yaml::from_str(&content).map_err(|source| GatewayProfileError::CatalogParse {
            path: absolute.clone(),
            source,
        })?;
    catalog
        .validate()
        .map_err(|source| GatewayProfileError::CatalogInvalid {
            path: absolute.clone(),
            source: Box::new(source),
        })?;
    gateway.catalog_path = Some(absolute);
    gateway.catalog = Some(catalog);
    Ok(())
}