systemprompt-identifiers 0.2.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
<div align="center">
  <a href="https://systemprompt.io">
    <img src="https://systemprompt.io/logo.svg" alt="systemprompt.io" width="150" />
  </a>
  <p><strong>Production infrastructure for AI agents</strong></p>
  <p><a href="https://systemprompt.io">systemprompt.io</a><a href="https://systemprompt.io/documentation">Documentation</a><a href="https://github.com/systempromptio/systemprompt-core">Core</a><a href="https://github.com/systempromptio/systemprompt-template">Template</a></p>
</div>

---


# systemprompt-identifiers

Core identifier types for systemprompt.io OS.

[![Crates.io](https://img.shields.io/crates/v/systemprompt-identifiers.svg)](https://crates.io/crates/systemprompt-identifiers)
[![Documentation](https://docs.rs/systemprompt-identifiers/badge.svg)](https://docs.rs/systemprompt-identifiers)
[![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-blue.svg)](https://github.com/systempromptio/systemprompt-core/blob/main/LICENSE)

## Overview

**Part of the Shared layer in the systemprompt.io architecture.**
**Infrastructure** · [Self-Hosted Deployment](https://systemprompt.io/features/self-hosted-ai-platform)

Provides strongly-typed wrappers for all domain identifiers, ensuring type safety
and preventing accidental mixing of different ID types.

## Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
systemprompt-identifiers = "0.0.1"
```

## Quick Example

```rust
use systemprompt_identifiers::{UserId, TaskId, ContextId};

let user_id = UserId::new();
let task_id = TaskId::new();
let context_id = ContextId::new();

println!("User: {}, Task: {}, Context: {}", user_id, task_id, context_id);
```

## Types

- `SessionId` - User session identifier
- `UserId` - User identifier
- `AgentId` - Agent UUID identifier
- `AgentName` - Agent name string
- `TaskId` - Task identifier
- `ContextId` - Conversation context identifier
- `TraceId` - Distributed tracing identifier
- `ClientId` - OAuth client identifier
- `McpExecutionId` - MCP execution tracking ID
- `McpServerId` - MCP server name
- `SkillId` - Skill identifier
- `SourceId` - Content source identifier
- `CategoryId` - Content category identifier
- `JwtToken` - JWT token wrapper

## Usage

All ID types implement:
- `Clone`, `Debug`, `PartialEq`, `Eq`, `Hash`
- `Serialize`, `Deserialize` (with `#[serde(transparent)]`)
- `AsRef<str>`, `Display`

## Feature Flags

| Feature | Default | Description |
|---------|---------|-------------|
| `sqlx` | No | SQLx type implementations for database queries |

## Dependencies

- `serde` - Serialization
- `uuid` - UUID generation
- `schemars` - JSON schema generation

## Usage

```rust
use systemprompt_identifiers::{AgentId, UserId};

fn main() {
    let agent = AgentId::new("developer_agent");
    let user = UserId::new("user_42");

    // Mixing newtype IDs is a compile error — the types are distinct.
    // let broken: AgentId = user; // error[E0308]: mismatched types

    println!("agent = {agent}, user = {user}");
}
```

## License

Business Source License 1.1 - See [LICENSE](https://github.com/systempromptio/systemprompt-core/blob/main/LICENSE) for details.