systemprompt-content 0.10.2

Markdown content management, sources, and event tracking for systemprompt.io AI governance dashboards. Governed publishing pipeline for the MCP governance platform.
Documentation
//! Dispatches parsed frontmatter to extension-provided frontmatter processors.

use super::scanner::ParsedFrontmatter;
use systemprompt_database::DbPool;
use systemprompt_extension::ExtensionRegistry;
use systemprompt_provider_contracts::FrontmatterContext;

pub async fn call_frontmatter_processors(
    db_pool: &DbPool,
    content_id_str: &str,
    slug: &str,
    source_name: &str,
    parsed: &ParsedFrontmatter,
) {
    let registry = ExtensionRegistry::discover().unwrap_or_else(|e| {
        tracing::error!(error = %e, "extension dependency cycle; using empty registry");
        ExtensionRegistry::new()
    });

    for ext in registry.extensions() {
        for processor in ext.frontmatter_processors() {
            let applies = processor.applies_to_sources();
            if !applies.is_empty() && !applies.contains(&source_name.to_string()) {
                continue;
            }

            let ctx = FrontmatterContext::new(
                content_id_str,
                slug,
                source_name,
                &parsed.raw_yaml,
                db_pool,
            );

            if let Err(e) = processor.process_frontmatter(&ctx).await {
                tracing::warn!(
                    processor = %processor.processor_id(),
                    content_id = %content_id_str,
                    error = %e,
                    "Frontmatter processor failed"
                );
            }
        }
    }
}