Chronicle

Identity (TypeID)

How Chronicle uses prefix-qualified, globally unique identifiers for every entity.

Every entity in Chronicle has a TypeID. TypeIDs are globally unique, sortable, URL-safe identifiers built on UUIDv7 with a human-readable prefix that tells you what kind of entity you're looking at.

A TypeID looks like this:

audit_01h455vb4pex5vsknk084sn02q

The audit prefix identifies this as an audit event. The suffix is a base32-encoded UUIDv7 that encodes creation time, so IDs sort chronologically.

The id package

The id package wraps the TypeID Go library (v2) with a single ID struct. All entity types share the same struct -- the prefix distinguishes them.

Creating IDs

import "github.com/xraph/chronicle/id"

auditID   := id.New(id.PrefixAudit)    // audit_01h455vb...
streamID  := id.New(id.PrefixStream)   // stream_01h455vb...
erasureID := id.New(id.PrefixErasure)  // erasure_01h455vb...

Convenience constructors: id.NewAuditID(), id.NewStreamID(), id.NewErasureID(), id.NewReportID(), id.NewPolicyID(), id.NewArchiveID(), id.NewPluginID().

Parsing IDs

parsed, err := id.Parse("audit_01h455vb4pex5vsknk084sn02q")
parsed, err := id.ParseWithPrefix("audit_01h455vb...", id.PrefixAudit)  // validates prefix
parsed, err := id.ParseAuditID("audit_01h455vb...")                     // convenience

Nil ID

var empty id.ID
empty.IsNil()  // true
empty.String() // ""
id.Nil.IsNil() // true

Database storage

id.ID implements Scanner and driver.Valuer. Stores as a string, returns NULL for nil IDs.

JSON serialization

id.ID implements TextMarshaler and TextUnmarshaler. Nil IDs serialize as empty strings.

Prefix reference

ConstantPrefixEntity
id.PrefixAuditauditAudit event
id.PrefixStreamstreamHash chain stream
id.PrefixErasureerasureGDPR erasure record
id.PrefixReportreportCompliance report
id.PrefixPolicyretpolRetention policy
id.PrefixArchivearchiveRetention archive
id.PrefixPluginpluginPlugin registration

On this page