Chronicle

Go Packages

Quick reference for all Chronicle Go packages and their public APIs.

This is a reference map of every package in the github.com/xraph/chronicle module, what it exports, and when you'd use it.

chronicle (root)

Import: github.com/xraph/chronicle

ExportTypePurpose
ChroniclestructRoot engine: record, query, verify
New(opts...)funcConstructor. Requires WithStore.
(c) Record(ctx, event)methodPersist a pre-built *audit.Event
(c) Info/Warning/Critical(ctx, action, resource, resourceID)methodStart an EventBuilder at the given severity
(c) Query(ctx, q)methodList events matching a filter
(c) Aggregate(ctx, q)methodGroup event counts
(c) ByUser(ctx, userID, opts)methodEvents for a specific user
(c) VerifyChain(ctx, input)methodVerify the full hash chain for a scope
(c) VerifyEvent(ctx, eventID)methodVerify a single event's hash (returns bool)
(c) Store()methodReturns the underlying chronicle.Storer
ConfigstructRuntime configuration
DefaultConfig()funcReturns sensible defaults
OptiontypeFunctional option type
WithStore(s)funcSet the backing chronicle.Storer (use store.NewAdapter(backend))
WithLogger(l)funcSet *slog.Logger
WithBatchSize(n)funcMax events per batch
WithFlushInterval(d)funcMax time between flushes
WithCryptoErasure(b)funcEnable GDPR AES-256-GCM encryption
EmitterinterfaceMinimal interface for DI injection: Info/Warning/Critical/Record/Query
StorerinterfaceMinimal store interface (avoids import cycle with store package)
StreamInfostructStream snapshot used by the record pipeline
EntitystructBase entity with CreatedAt, UpdatedAt
ErrNoStore, ErrEventNotFound, ErrStreamNotFound, ErrChainBroken, ErrSubjectNotFound, ErrPolicyNotFound, ErrReportNotFound, ErrErasureNotFound, ErrErasureKeyNotFound, ErrInvalidQuery, ErrUnauthorized, ErrStoreClosed, ErrMigrationFailederrorsSentinel errors

audit

Import: github.com/xraph/chronicle/audit

ExportTypePurpose
EventstructImmutable audit event
SeverityInfo, SeverityWarning, SeverityCriticalconstSeverity level strings
OutcomeSuccess, OutcomeFailure, OutcomeDeniedconstOutcome strings
QuerystructFilter + pagination for event listing
QueryResultstructEvents []*Event, Total int64
AggregateQuerystructGroupBy field, filters
AggregateResultstructBuckets []AggregateItem
CountQuerystructCount-only query (no event fetch)
TimeRangestructFrom, To for ByUser
StoreinterfaceAppend, AppendBatch, Get, Query, Aggregate, ByUser, Count, LastSequence, LastHash

stream

Import: github.com/xraph/chronicle/stream

ExportTypePurpose
StreamstructHash chain head: ID, AppID, TenantID, HeadHash, HeadSeq
ListOptsstructLimit, Offset for listing
StoreinterfaceCreateStream, GetStream, GetStreamByScope, ListStreams, UpdateStreamHead

hash

Import: github.com/xraph/chronicle/hash

ExportTypePurpose
Chain(event *audit.Event, prevHash string)funcCompute SHA-256 hash for an event

verify

Import: github.com/xraph/chronicle/verify

ExportTypePurpose
InputstructStreamID, FromSeq, ToSeq, AppID, TenantID
ReportstructValid, Verified, Gaps []uint64, Tampered []uint64, FirstEvent, LastEvent
StoreinterfaceEventRange, Gaps

store

Import: github.com/xraph/chronicle/store

ExportTypePurpose
StoreinterfaceComposite: all 6 sub-stores + Migrate + Ping + Close
NewAdapter(s Store)funcBridges store.Storechronicle.Storer

crypto

Import: github.com/xraph/chronicle/crypto

ExportTypePurpose
EncryptorstructAES-256-GCM encrypt/decrypt
NewEncryptor()funcConstructor
Encrypt(key, plaintext)methodReturns ciphertext with random nonce
Decrypt(key, ciphertext)methodReturns plaintext
InMemoryKeyStorestructIn-memory key store (dev/test only)
NewInMemoryKeyStore()funcConstructor
KeyStoreinterfaceGetOrCreate, Get, Delete

erasure

Import: github.com/xraph/chronicle/erasure

ExportTypePurpose
ErasurestructErasure record entity
InputstructSubjectID, Reason, RequestedBy
ResultstructID, SubjectID, EventsAffected, KeyDestroyed
ServicestructErase logic: find events → mark erased → destroy key
NewService(store, keyStore)funcConstructor
StoreinterfaceSaveErasure, GetErasure, ListErasures, MarkEventsErased

compliance

Import: github.com/xraph/chronicle/compliance

ExportTypePurpose
EnginestructReport generation
NewEngine(auditStore, verifyStore, reportStore, logger)funcConstructor
ReportstructGenerated compliance report
SectionstructReport section with events and stats
StatsstructTotalEvents, CriticalEvents, FailedEvents, DeniedEvents
DateRangestructFrom, To time range
SOC2Input, HIPAAInput, EUAIActInput, CustomInputstructReport inputs
FormatJSON, FormatCSV, FormatMarkdown, FormatHTML, FormatPDFconstExport format constants
ReportStoreinterfaceSaveReport, GetReport, ListReports, DeleteReport

retention

Import: github.com/xraph/chronicle/retention

ExportTypePurpose
PolicystructRetention policy: Category, Duration, Archive, AppID
ArchivestructArchive record: PolicyID, EventsArchived, EventsPurged
EnforcerstructPolicy runner
NewEnforcer(store, archiveSink, logger)funcConstructor
EnforceResultstructArchived, Purged, Retained int64
StoreinterfaceSavePolicy, GetPolicy, ListPolicies, DeletePolicy, EventsOlderThan, SaveArchive, ListArchives

sink

Import: github.com/xraph/chronicle/sink

ExportTypePurpose
SinkinterfaceName, Write, Flush, Close
NewStdout()funcStdout sink
NewFile(path)funcFile sink
NewS3(client, bucket, prefix)funcS3 sink
NewMulti(sinks...)funcFan-out sink

plugin

Import: github.com/xraph/chronicle/plugin

ExportTypePurpose
PlugininterfaceName() string base interface
OnInit, OnShutdowninterfaceLifecycle hooks
BeforeRecordinterfaceOnBeforeRecord(ctx, event) error
AfterRecordinterfaceOnAfterRecord(ctx, event) error
SinkProviderinterfaceSink() sink.Sink
AlertHandlerinterfaceOnAlert(ctx, event, rule) error
ExporterinterfaceFormat() / Export(...)
ComplianceReporterinterfaceReportType() string
RegistrystructDiscovery-based plugin dispatcher
NewRegistry(logger)funcConstructor
AlertRulestructName, Severity, Category, Outcome for alert matching
ErrSkipEventerrorReturn from BeforeRecord to silently drop the event

batcher

Import: github.com/xraph/chronicle/batcher

ExportTypePurpose
BatcherstructAccumulates events and flushes in batches
New(store, size, interval)funcConstructor

scope

Import: github.com/xraph/chronicle/scope

ExportTypePurpose
InfostructAppID, TenantID, UserID, IP
WithAppID(ctx, s)funcStore AppID in context
WithTenantID(ctx, s)funcStore TenantID in context
WithUserID(ctx, s)funcStore UserID in context
WithIP(ctx, s)funcStore IP in context
WithInfo(ctx, info)funcStore all scope fields at once
FromContext(ctx)funcExtract scope.Info
FromRequest(r)funcExtract scope + IP from HTTP request
ApplyToEvent(ctx, event)funcStamp scope fields onto an event
ApplyToQuery(ctx, q)funcEnforce tenant scope on an audit.Query
ApplyToAggregateQuery(ctx, q)funcEnforce tenant scope on an audit.AggregateQuery
ApplyToCountQuery(ctx, q)funcEnforce tenant scope on an audit.CountQuery

id

Import: github.com/xraph/chronicle/id

ExportTypePurpose
IDstructUnified TypeID
PrefixtypeString alias for entity prefix
PrefixAudit, PrefixStream, PrefixErasure, PrefixReport, PrefixPolicy, PrefixArchive, PrefixPluginconstEntity prefixes
New(prefix)funcCreate a new ID with the given prefix
NewAuditID(), NewStreamID(), NewErasureID(), NewReportID(), NewPolicyID(), NewArchiveID()funcPer-entity constructors
Parse(s)funcParse TypeID string (any prefix)
ParseAuditID(s), ParseStreamID(s), etc.funcParse with prefix validation
ParseAny(s)funcAlias for Parse

handler

Import: github.com/xraph/chronicle/handler

ExportTypePurpose
APIstructHTTP handler with all 21 routes
New(deps, router)funcConstructor
DependenciesstructAuditStore, VerifyStore, ErasureStore, RetentionStore, ReportStore, Compliance, Retention, Logger
RegisterRoutes(router)methodMount all routes
Handler()methodReturns standalone http.Handler

extension

Import: github.com/xraph/chronicle/extension

ExportTypePurpose
ExtensionstructForge extension wrapping the full Chronicle stack
New(opts...)funcConstructor
OptiontypeFunctional option type
WithStore(s), WithBatchSize(n), WithFlushInterval(d), WithCryptoErasure(b), WithRetentionInterval(d), WithArchiveSink(s), WithLogger(l), WithDisableRoutes(b), WithDisableMigrate(b)funcOption constructors
Chronicle()methodReturns *chronicle.Chronicle
Emitter()methodReturns chronicle.Emitter
ComplianceEngine()methodReturns *compliance.Engine
RetentionEnforcer()methodReturns *retention.Enforcer
API()methodReturns *handler.API
Handler()methodReturns standalone http.Handler

Store backends

PackageDriver
store/memoryIn-memory (zero-dependency, for tests)
store/postgresPostgreSQL via pgx/v5
store/bunPostgreSQL / MySQL / SQLite via Bun ORM
store/sqliteSQLite via modernc.org/sqlite (pure Go, no CGO)

On this page