agileplus-trace-validator 0.3.0

Typed intent graphs for engineering work — convert prompts into validated DAGs of intents, features, tasks, tests, and edges, then store, query, and serve them from Rust, HTTP, or MCP.
Documentation
//! Graph metadata validation.

use crate::{ValidationError, ValidationResult};
use agileplus_domain::intent_graph::GraphMetadata;

/// Validate graph metadata fields (version, schema_uri, created_at, counts).
pub fn validate_metadata(metadata: &GraphMetadata) -> ValidationResult {
    let mut errors = Vec::new();

    if metadata.version.trim().is_empty() {
        errors.push(ValidationError::MetadataError(
            "Metadata version is empty".to_string(),
        ));
    }

    if metadata.schema_uri.trim().is_empty() {
        errors.push(ValidationError::MetadataError(
            "Metadata schema_uri is empty".to_string(),
        ));
    }

    if metadata.created_at.trim().is_empty() {
        errors.push(ValidationError::MetadataError(
            "Metadata created_at is empty".to_string(),
        ));
    }

    if let Some(c) = metadata.node_count {
        if c > 0 && metadata.edge_count.is_none() {
            errors.push(ValidationError::MetadataError(
                "Metadata has node_count but no edge_count".to_string(),
            ));
        }
    }

    if errors.is_empty() {
        Ok(())
    } else {
        Err(errors)
    }
}