liminal-server 0.27.7

Standalone server for the liminal messaging bus
Documentation
//! ACCESS-013 R2: where the agent registry's bounds may be written.
//!
//! `[agents]` at the top level is the one place an open exchange (no
//! `[auth]`) can open its registry; a gated exchange may write it there or
//! under `[auth.lys]`, never both, so there is one source of truth. The
//! bounds themselves are checked by `AgentsConfig::validate` from whichever
//! place answers.

use crate::config::types::ServerConfig;

pub(super) fn validate_agent_places(config: &ServerConfig, errors: &mut Vec<String>) {
    let lys = config.auth.as_ref().and_then(|auth| auth.lys.as_ref());
    if config.agents.is_some() && lys.is_some_and(|lys| lys.agents.is_some()) {
        errors.push(
            "agents are written once: at the top level or under [auth.lys], not both".to_owned(),
        );
    }
    if config.agents.is_some() && config.auth.is_some() && lys.is_none() {
        errors.push(
            "agents: a gated exchange places stations in Lys, write [auth.lys] or remove [auth]"
                .to_owned(),
        );
    }
    // Each station's inbox is a channel registered at runtime, so a registry
    // without the bound is refused here by name, not at a seat's first send.
    if config.agents_config().is_some() && config.limits.max_channels.is_none() {
        errors.push(
            "agents: each station's inbox is a channel registered at runtime; write [limits] \
             max_channels"
                .to_owned(),
        );
    }
    if let Some(Err(error)) = config.agents.map(|agents| agents.validate()) {
        errors.push(format!("agents: {error}"));
    }
}