Expand description
Typed newtype identifiers for systemprompt.io.
Every entity in the platform is referenced through a wrapper newtype
rather than a raw String.
This crate provides both the macros that generate those wrappers
(define_id!, define_token!) and the canonical concrete types
(UserId, AgentId, TaskId, TraceId, ContextId, SessionId,
McpServerId, …).
Boundary types for talking to the database — DbValue, ToDbValue,
FromDbValue, JsonRow — also live here so that identifier modules
can interoperate without depending on the database crate.
§Construction
use systemprompt_identifiers::{TaskId, UserId};
// A value already known to be valid (a decoded DB row).
let task = TaskId::new("task_abc");
// A value from outside (header, path segment, JWT claim): validate it.
let user = UserId::try_new(raw_sub)?;
// Mint a fresh UUID-backed identifier.
let fresh = UserId::generate();Validated identifiers (ContextId, Email, ProfileName, ValidatedUrl,
ValidatedFilePath, RoleId, …) expose only the fallible try_new
constructor returning error::IdValidationError; there is no
infallible new that could panic on runtime input. Values
minted by the platform itself (ContextId::generate, AgentName::system)
come from dedicated constructors.
Checked identifiers (UserId, ServiceName, AgentName, McpServerId,
McpToolName, PluginId, SkillId, …) have both: try_new validates
input from outside, new accepts a value already known valid (a decoded
row, a configuration key validated at load). They implement no
From<String>, and their Deserialize/FromStr validate.
“Absent” is Option<Id>, never a sentinel value such as "unset",
"unknown" or the empty string.
gateway_hash is the deterministic prefix hash that mints a
GatewayConversationId identically on both sides of the bridge boundary.
§Feature flags
| Feature | Effect |
|---|---|
| (default) | Pure-Rust types only. |
sqlx | Derives sqlx::Type on every identifier, allowing direct binding in query_as! macros. |
Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.
Re-exports§
pub use db_value::DbValue;pub use db_value::FromDbValue;pub use db_value::JsonRow;pub use db_value::ToDbValue;pub use db_value::parse_database_datetime;
Modules§
- db_
value - Database-value abstraction shared between repository code and the identifier crate.
- error
- Error types raised by identifier validation and database value conversion.
- gateway_
hash - Stable conversation-prefix hash used to mint deterministic
GatewayConversationIds on both sides of the bridge boundary. - headers
- Canonical HTTP header name constants used throughout the platform for propagating trace, session, and authorization context across services.
- macros
- Declarative macros that generate the typed identifier and token newtypes.
Macros§
Structs§
- Access
Token Id - Actor
- Advisory
Lock Key - AgentId
- Agent
Name - Agent
RunId - Agent
RunOrigin Id - AiGateway
Policy Id - AiQuota
Bucket Id - AiRequest
Id - AiSafety
Finding Id - AiTool
Call Id - Analytics
Event Id - ApiKey
Id - ApiKey
Secret - Artifact
Element Id - Artifact
Id - Authorization
Code - CallId
- Campaign
Id - Category
Id - Challenge
Id - Client
Id - Client
Session Id - Cloud
AppId - Cloud
Auth Token - Cloud
Plan Id - Cloud
User Id - Comms
Message Id - Config
Id - Connection
Id - Connector
AppId - Connector
Installation Id - Consumer
Installation Id - Content
Hash - Content
Id - Context
Id - Credential
Id - Department
Id - Department
Name - Deployment
Organization Uuid - Device
Cert Id - Device
Id - Distribution
Id - Document
Access Request Id - Document
Comment Id - Document
Edit Session Id - Document
Folder Id - Document
Id - Document
Node Id - Document
OpId - Document
Proposal Id - Document
Revision Id - Document
Template Id - Document
Upload Id - Drive
Device Id - Elevated
JobId - Endpoint
Id - Engagement
Event Id - Enterprise
License Id - Event
Outbox Id - Execution
Step Id - Extension
Id - External
Agent Id - FileId
- Gateway
Conversation Id - HookId
- Hook
Session Id - Host
Session Id - IdpTenant
Id - Installation
Receipt Id - Installation
Session Binding Id - Instance
Id - Invalid
Quota Subject Kind - Inventory
Entry Id - Issue
Report Id - JobName
- JwtToken
- Lease
Key - Library
Artifact Id - Link
Click Id - LinkId
- Locale
Code - LogId
- Managed
Reconciliation Id - Managed
Resource Id - Managed
Source Id - Marketplace
Id - Marketplace
Rule Id - McpExecution
Id - McpServer
Id - McpSession
Id - McpTool
Name - Message
Id - ModelId
- Native
Session Id - Notification
Id - Notification
Rule Id - Notification
Stream Id - Notification
Subscription Id - Plugin
Id - Policy
Id - Policy
Version - PriceId
- Profile
Name - Provider
Id - Provider
Request Id - Publication
Id - Publication
Review Id - Quota
Subject Id - Refresh
Token Family Id - Refresh
Token Id - Resource
Invocation Id - Resource
Revision Id - RoleId
- RouteId
- RuleId
- Rule
Name - Scheduled
JobId - Scope
Dimension - Secret
Name - Secret
Pattern Id - Section
Id - Service
Name - Session
Id - Session
Token - SkillId
- Skill
Name - Slack
Channel Id - Slack
User Id - Slack
Workspace Id - Source
Id - Source
Snapshot Id - SsoAssertion
Id - SsoProvider
Id - SsoRequest
Id - TagId
- TaskId
- Teams
AppId - Teams
Conversation Id - Teams
Tenant Id - Teams
User Id - Tenant
Id - TokenId
- TraceId
- UserId
- Validated
File Path - Validated
Url - Webhook
Endpoint Id - Withdrawal
Proposal Id
Enums§
- Actor
Kind - Actor
Kind Tag - Discriminant-only view of
ActorKind, bound to theactor_kindcolumn ingovernance_decisions. - Client
Type - Quota
Subject Kind - Session
Source