id

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package id defines TypeID-based identity types for all Sentinel entities.

Every entity in Sentinel uses a single ID struct with a prefix that identifies the entity type. IDs are K-sortable (UUIDv7-based), globally unique, and URL-safe in the format "prefix_suffix".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyID

type AnyID = ID

AnyID is a type alias that accepts any valid prefix.

type BaselineID

type BaselineID = ID

BaselineID is a type-safe identifier for baselines (prefix: "base").

type CaseID

type CaseID = ID

CaseID is a type-safe identifier for test cases (prefix: "tcase").

type EvalResultID

type EvalResultID = ID

EvalResultID is a type-safe identifier for evaluation results (prefix: "eres").

type EvalRunID

type EvalRunID = ID

EvalRunID is a type-safe identifier for evaluation runs (prefix: "erun").

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID is the primary identifier type for all Sentinel entities. It wraps a TypeID providing a prefix-qualified, globally unique, sortable, URL-safe identifier in the format "prefix_suffix".

var Nil ID

Nil is the zero-value ID.

func MustParse

func MustParse(s string) ID

MustParse is like Parse but panics on error. Use for hardcoded ID values.

func MustParseWithPrefix

func MustParseWithPrefix(s string, expected Prefix) ID

MustParseWithPrefix is like ParseWithPrefix but panics on error.

func New

func New(prefix Prefix) ID

New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).

func NewBaselineID

func NewBaselineID() ID

NewBaselineID generates a new unique baseline ID.

func NewCaseID

func NewCaseID() ID

NewCaseID generates a new unique case ID.

func NewEvalResultID

func NewEvalResultID() ID

NewEvalResultID generates a new unique eval result ID.

func NewEvalRunID

func NewEvalRunID() ID

NewEvalRunID generates a new unique eval run ID.

func NewPromptVersionID

func NewPromptVersionID() ID

NewPromptVersionID generates a new unique prompt version ID.

func NewRedTeamID

func NewRedTeamID() ID

NewRedTeamID generates a new unique red team ID.

func NewSuiteID

func NewSuiteID() ID

NewSuiteID generates a new unique suite ID.

func Parse

func Parse(s string) (ID, error)

Parse parses a TypeID string (e.g., "suite_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.

func ParseAny

func ParseAny(s string) (ID, error)

ParseAny parses a string into an ID without type checking the prefix.

func ParseBaselineID

func ParseBaselineID(s string) (ID, error)

ParseBaselineID parses a string and validates the "base" prefix.

func ParseCaseID

func ParseCaseID(s string) (ID, error)

ParseCaseID parses a string and validates the "tcase" prefix.

func ParseEvalResultID

func ParseEvalResultID(s string) (ID, error)

ParseEvalResultID parses a string and validates the "eres" prefix.

func ParseEvalRunID

func ParseEvalRunID(s string) (ID, error)

ParseEvalRunID parses a string and validates the "erun" prefix.

func ParsePromptVersionID

func ParsePromptVersionID(s string) (ID, error)

ParsePromptVersionID parses a string and validates the "pver" prefix.

func ParseRedTeamID

func ParseRedTeamID(s string) (ID, error)

ParseRedTeamID parses a string and validates the "rteam" prefix.

func ParseSuiteID

func ParseSuiteID(s string) (ID, error)

ParseSuiteID parses a string and validates the "suite" prefix.

func ParseWithPrefix

func ParseWithPrefix(s string, expected Prefix) (ID, error)

ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.

func (ID) IsNil

func (i ID) IsNil() bool

IsNil reports whether this ID is the zero value.

func (ID) MarshalBSONValue

func (i ID) MarshalBSONValue() (bsonType byte, data []byte, err error)

MarshalBSONValue satisfies bson.ValueMarshaler (mongo-driver v2) so the ID is stored as a BSON string instead of an opaque struct. No bson import needed because Go uses structural typing for interface satisfaction.

func (ID) MarshalText

func (i ID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ID) Prefix

func (i ID) Prefix() Prefix

Prefix returns the prefix component of this ID.

func (*ID) Scan

func (i *ID) Scan(src any) error

Scan implements sql.Scanner for database retrieval.

func (ID) String

func (i ID) String() string

String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.

func (*ID) UnmarshalBSONValue

func (i *ID) UnmarshalBSONValue(t byte, data []byte) error

UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ID) Value

func (i ID) Value() (driver.Value, error)

Value implements driver.Valuer for database storage. Returns nil for the Nil ID so that optional foreign key columns store NULL.

type Prefix

type Prefix string

Prefix identifies the entity type encoded in a TypeID.

const (
	PrefixSuite         Prefix = "suite"
	PrefixCase          Prefix = "tcase"
	PrefixEvalRun       Prefix = "erun"
	PrefixEvalResult    Prefix = "eres"
	PrefixBaseline      Prefix = "base"
	PrefixRedTeam       Prefix = "rteam"
	PrefixPromptVersion Prefix = "pver"
)

Prefix constants for all Sentinel entity types.

type PromptVersionID

type PromptVersionID = ID

PromptVersionID is a type-safe identifier for prompt versions (prefix: "pver").

type RedTeamID

type RedTeamID = ID

RedTeamID is a type-safe identifier for red team sessions (prefix: "rteam").

type SuiteID

type SuiteID = ID

SuiteID is a type-safe identifier for evaluation suites (prefix: "suite").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL