Chronicle

Entities

The core data types in Chronicle — events, streams, erasures, policies, archives, and reports.

Chronicle defines a small set of entity types that flow through the system. All entities embed chronicle.Entity which carries CreatedAt and UpdatedAt timestamps.

audit.Event

audit.Event is the central type. It is immutable once recorded — there is no update or delete path for individual events.

Identity fields

FieldTypeDescription
IDid.IDTypeID with audit_ prefix
Timestamptime.TimeWhen the event occurred
Sequenceuint64Monotonically increasing per stream

Hash chain fields

FieldTypeDescription
HashstringSHA-256 hash of this event's content
PrevHashstringHash of the predecessor event (empty for first)
StreamIDid.IDThe chain (stream_ ID) this event belongs to

Scope fields

FieldTypeDescription
AppIDstringApplication identifier (required)
TenantIDstringTenant within the application
UserIDstringUser who performed the action
IPstringClient IP address

Scope fields are automatically applied from the context by chronicle.Record via scope.ApplyToEvent.

Action fields

FieldTypeDescription
ActionstringVerb — what happened (e.g. "login", "delete")
ResourcestringNoun — what was acted on (e.g. "session", "user")
CategorystringLogical group (e.g. "auth", "billing")

Action, Resource, and Category are required fields. Chronicle rejects events missing any of them.

Detail fields

FieldTypeDescription
ResourceIDstringID of the specific resource instance
Metadatamap[string]anyArbitrary key-value context
Outcomestring"success", "failure", or "denied"
Severitystring"info", "warning", or "critical"
ReasonstringHuman-readable explanation

GDPR fields

FieldTypeDescription
SubjectIDstringData subject for GDPR crypto-erasure
EncryptionKeyIDstringKey ID used to encrypt sensitive payload

Erasure state fields

These fields are set by the erasure engine — never by the caller.

FieldTypeDescription
ErasedboolTrue after crypto-erasure
ErasedAt*time.TimeWhen erasure occurred
ErasureIDstringID of the erasure record

stream.Stream

A Stream is the head pointer of a hash chain. One stream exists per app+tenant combination.

FieldTypeDescription
IDid.IDTypeID with stream_ prefix
AppIDstringApplication identifier
TenantIDstringTenant identifier
HeadHashstringHash of the most recently appended event
HeadSequint64Sequence number of the most recently appended event

erasure.Erasure

Records a completed GDPR erasure operation.

FieldTypeDescription
IDid.IDTypeID with erasure_ prefix
SubjectIDstringThe erased data subject
AppID / TenantIDstringScope
ReasonstringErasure reason (e.g. "GDPR Article 17")
RequestedBystringWho initiated the erasure
KeyDestroyedboolWhether the encryption key was destroyed
EventsAffectedintNumber of events that were erased

retention.Policy

A retention policy governs how long events are kept and what happens when they age out.

FieldTypeDescription
IDid.IDTypeID with retpol_ prefix
CategorystringEvent category this policy applies to (empty = all)
Durationtime.DurationHow long to keep events
ArchiveboolIf true, write to archive sink before purge
AppID / TenantIDstringScope

retention.Archive

Records the output of a retention enforcement run.

FieldTypeDescription
IDid.IDTypeID with archive_ prefix
PolicyIDid.IDThe policy that triggered this archive
EventsArchivedintEvents written to the archive sink
EventsPurgedintEvents removed from the store

compliance.Report

Stores a generated compliance report.

FieldTypeDescription
IDid.IDTypeID with report_ prefix
Typestring"soc2", "hipaa", "euaiact", or "custom"
PeriodDateRangeFrom / To time range
Sections[]SectionReport sections with events and stats
Stats*StatsAggregate counts (total, critical, failed, denied)
Verification*verify.ReportOptional hash chain integrity snapshot
GeneratedBystringRequestor identity
FormatFormatExport format used
Data[]byteRaw exported bytes

verify.Report

The output of a hash chain verification run.

FieldTypeDescription
ValidboolTrue if no gaps and no tampered hashes
Verifiedint64Number of events checked
Gaps[]uint64Missing sequence numbers (deleted events)
Tampered[]uint64Sequence numbers with hash mismatches
FirstEventuint64First sequence checked
LastEventuint64Last sequence checked

chronicle.Entity

chronicle.Entity is the base struct embedded by every stored entity. It provides common timestamp fields:

FieldTypeDescription
CreatedAttime.TimeWhen the record was first created
UpdatedAttime.TimeWhen the record was last updated

Use chronicle.NewEntity() to initialise a new record with both timestamps set to the current UTC time:

import "github.com/xraph/chronicle"

r := SomeEntity{Entity: chronicle.NewEntity()}

chronicle.Entity is embedded by stream.Stream, erasure.Erasure, retention.Policy, retention.Archive, and compliance.Report. The immutable audit.Event does not embed it — events carry their own Timestamp field set at recording time.

On this page