systemprompt-identifiers 0.9.1

Typed newtype identifiers (UserId, TraceId, AgentId, McpServerId…) for systemprompt.io AI governance infrastructure. Enforces type-safe IDs across every boundary in the MCP governance pipeline.
Documentation
//! Opaque request identifier echoed by upstream model providers.
//!
//! Captured for observability when a provider returns a trace token in
//! its response (e.g. via `x-context-id` or analogous headers). The shape
//! is provider-defined, so this id is only validated for non-empty and a
//! sane upper length bound.

use crate::error::IdValidationError;

const MAX_LEN: usize = 256;

fn validate(value: &str) -> Result<(), IdValidationError> {
    if value.is_empty() {
        return Err(IdValidationError::empty("ProviderRequestId"));
    }
    if value.len() > MAX_LEN {
        return Err(IdValidationError::invalid(
            "ProviderRequestId",
            "exceeds maximum length",
        ));
    }
    Ok(())
}

crate::define_id!(ProviderRequestId, validated, schema, validate);