ids

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ids is part of the GoFastr harness.

See docs/harness-architecture.md for the architecture this package implements.

Package ids defines the typed identifier strings used across the harness wire protocol and persistence layer. All IDs are ULID-derived with a typed prefix so a string can be inspected without context.

Formats (normative — see docs/harness-architecture.md § Glossary):

SessionID    sess_<ULID>   one per EngineRun
LogID        log_<ULID>    persistence-layer ID
CallID       call_<ULID>   one per tool call
JTI          tok_<ULID>    token ID (revocation key)
ClientID     cli_<ULID>    stable for the lifetime of a client attach

Branch ID rewrite is deterministic from (source_id, new_log_id) so two clients branching the same boundary produce the same new IDs.

Index

Constants

View Source
const (
	PrefixSession = "sess"
	PrefixLog     = "log"
	PrefixCall    = "call"
	PrefixToken   = "tok"
	PrefixClient  = "cli"
)

Prefix constants — keep in lockstep with the doc.

Variables

View Source
var ErrInvalidPrefix = errors.New("ids: invalid prefix")

ErrInvalidPrefix is returned when a parsed ID has the wrong prefix.

Functions

func RewriteForBranch

func RewriteForBranch(sourceID string, newLogID LogID) (string, error)

RewriteForBranch deterministically derives a new ID from a source ID and the new LogID it belongs to, per the doc's branch ID-rewrite rule.

Two clients branching the same source ID at the same boundary with the same destination LogID produce the same rewritten ID. This is the property the replay/diff tools rely on.

The input may be any prefixed ID; the rewritten ID keeps the same prefix.

func ValidCall

func ValidCall(s CallID) bool

ValidCall reports whether s is a syntactically valid CallID.

func ValidClient

func ValidClient(s ClientID) bool

ValidClient reports whether s is a syntactically valid ClientID.

func ValidJTI

func ValidJTI(s JTI) bool

ValidJTI reports whether s is a syntactically valid JTI.

func ValidLog

func ValidLog(s LogID) bool

ValidLog reports whether s is a syntactically valid LogID.

func ValidSession

func ValidSession(s SessionID) bool

ValidSession reports whether s is a syntactically valid SessionID.

Types

type CallID

type CallID string

Typed ID strings. These are stringly-typed so they serialize naturally over JSON without custom marshalers, but separate Go types so the compiler catches misuse (e.g. passing a SessionID where a LogID is expected).

func NewCallID

func NewCallID() CallID

NewCallID returns a fresh CallID.

func ParseCall

func ParseCall(s string) (CallID, error)

ParseCall parses a CallID string and validates the prefix.

type ClientID

type ClientID string

Typed ID strings. These are stringly-typed so they serialize naturally over JSON without custom marshalers, but separate Go types so the compiler catches misuse (e.g. passing a SessionID where a LogID is expected).

func NewClientID

func NewClientID() ClientID

NewClientID returns a fresh ClientID.

func ParseClient

func ParseClient(s string) (ClientID, error)

ParseClient parses a ClientID string and validates the prefix.

type JTI

type JTI string

Typed ID strings. These are stringly-typed so they serialize naturally over JSON without custom marshalers, but separate Go types so the compiler catches misuse (e.g. passing a SessionID where a LogID is expected).

func NewJTI

func NewJTI() JTI

NewJTI returns a fresh token ID.

func ParseJTI

func ParseJTI(s string) (JTI, error)

ParseJTI parses a JTI string and validates the prefix.

type LogID

type LogID string

Typed ID strings. These are stringly-typed so they serialize naturally over JSON without custom marshalers, but separate Go types so the compiler catches misuse (e.g. passing a SessionID where a LogID is expected).

func NewLogID

func NewLogID() LogID

NewLogID returns a fresh LogID.

func ParseLog

func ParseLog(s string) (LogID, error)

ParseLog parses a LogID string and validates the prefix.

type SessionID

type SessionID string

Typed ID strings. These are stringly-typed so they serialize naturally over JSON without custom marshalers, but separate Go types so the compiler catches misuse (e.g. passing a SessionID where a LogID is expected).

func NewSessionID

func NewSessionID() SessionID

NewSessionID returns a fresh SessionID.

func ParseSession

func ParseSession(s string) (SessionID, error)

ParseSession parses a SessionID string and validates the prefix.

Jump to

Keyboard shortcuts

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