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 ¶
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.
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 ¶
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.