vc-runtime 0.1.0

Runtime backend for Visual Compiler
Documentation
//! ComfyUI-specific deterministic validation.

use super::super::{BackendValidationError, ConfigError};
use crate::config::model::{AppConfig, BackendOptions};

pub fn validate(config: &AppConfig) -> Result<(), ConfigError> {
    for (backend_name, backend) in &config.backends {
        match &backend.options {
            BackendOptions::ComfyUi(cfg) => {
                if cfg.timeout_secs == 0 {
                    return Err(BackendValidationError::ZeroTimeout {
                        backend: backend_name.to_owned(),
                    }
                    .into());
                }
                if cfg.poll_timeout_secs == 0 {
                    return Err(BackendValidationError::ZeroPollTimeout {
                        backend: backend_name.to_owned(),
                    }
                    .into());
                }
                if cfg.poll_interval_ms == 0 {
                    return Err(BackendValidationError::ZeroPollInterval {
                        backend: backend_name.to_owned(),
                    }
                    .into());
                }
                if !matches!(cfg.base_url.scheme(), "http" | "https") {
                    return Err(BackendValidationError::UnsupportedScheme {
                        backend: backend_name.to_owned(),
                        scheme: cfg.base_url.scheme().to_owned(),
                    }
                    .into());
                }
            }
            BackendOptions::Python(_) | BackendOptions::Dummy(_) => {
                // No backend-specific validation required at this stage.
            }
        }
    }
    Ok(())
}