id

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package id provides the CheckpointID type for identifying checkpoints. This is a separate package to avoid import cycles between paths, trailers, and checkpoint.

Index

Constants

View Source
const Pattern = `[0-9a-f]{12}`

Pattern is the regex pattern for a valid checkpoint ID: exactly 12 lowercase hex characters. Exported for use in other packages (e.g., trailers) to avoid pattern duplication.

View Source
const ShortIDLength = 12

ShortIDLength is the standard length for truncating IDs for display purposes. Used for tool use IDs, session IDs, and commit hashes in logs and messages.

Variables

This section is empty.

Functions

func Validate

func Validate(s string) error

Validate checks if a string is a valid checkpoint ID format. Returns an error if invalid, nil if valid.

Types

type CheckpointID

type CheckpointID string

CheckpointID is a 12-character hex identifier for checkpoints. It's used to link code commits to metadata on the entire/checkpoints/v1 branch.

const EmptyCheckpointID CheckpointID = ""

EmptyCheckpointID represents an unset or invalid checkpoint ID.

func Generate

func Generate() (CheckpointID, error)

Generate creates a new random 12-character hex checkpoint ID.

func MustCheckpointID

func MustCheckpointID(s string) CheckpointID

MustCheckpointID creates a CheckpointID from a string, panicking if invalid. Use only when the ID is known to be valid (e.g., from trusted sources).

func NewCheckpointID

func NewCheckpointID(s string) (CheckpointID, error)

NewCheckpointID creates a CheckpointID from a string, validating its format. Returns an error if the string is not a valid 12-character hex ID.

func (CheckpointID) IsEmpty

func (id CheckpointID) IsEmpty() bool

IsEmpty returns true if the checkpoint ID is empty or unset.

func (CheckpointID) MarshalJSON

func (id CheckpointID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (CheckpointID) Path

func (id CheckpointID) Path() string

Path returns the sharded path for this checkpoint ID on entire/checkpoints/v1. Uses first 2 characters as shard (256 buckets), remaining as folder name. Example: "a3b2c4d5e6f7" -> "a3/b2c4d5e6f7"

func (CheckpointID) String

func (id CheckpointID) String() string

String returns the checkpoint ID as a string.

func (*CheckpointID) UnmarshalJSON

func (id *CheckpointID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler with validation. Returns an error if the JSON string is not a valid 12-character hex ID. Empty strings are allowed and result in EmptyCheckpointID.

Jump to

Keyboard shortcuts

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