Versions in this module Expand all Collapse all v0 v0.2.0 Jul 20, 2026 Changes in this version + var ErrInvalidPath = errors.New("chronicle: invalid path") + type FieldHistoryOption func(*fieldHistoryOpts) + func FieldHistoryDescending() FieldHistoryOption + type FieldRevision struct + Actor Actor + From FieldValue + Intent Intent + Path string + Reason string + To FieldValue + TxAt time.Time + ValidFrom time.Time + ValidTo time.Time + type FieldValue struct + Present bool + Value any + func (v FieldValue) IsNull() bool type Log + func (l *Log) FieldHistory(ctx context.Context, kind, entityID, path string, as As, ...) ([]FieldRevision, error) + type PathError struct + Path string + Reason string + func (e *PathError) Error() string + func (e *PathError) Unwrap() error v0.1.0 Jul 20, 2026 Changes in this version + const CipherAESGCM1 + const DefaultWriteRetries + const KeySize + const MetaChain + const MetaCipher + const MetaReservedPrefix + const MetaSubject + var ErrClosed = errors.New("chronicle: store closed") + var ErrCodec = errors.New("chronicle: codec") + var ErrConflict = errors.New("chronicle: write conflict") + var ErrCurrentRecord = errors.New("chronicle: record is current belief") + var ErrHoldExists = errors.New("chronicle: hold already exists") + var ErrHoldReleased = errors.New("chronicle: hold already released") + var ErrInvalidCursor = errors.New("chronicle: invalid cursor") + var ErrInvalidField = errors.New("chronicle: invalid field") + var ErrInvalidInterval = errors.New("chronicle: invalid interval") + var ErrInvalidMeta = errors.New("chronicle: invalid metadata") + var ErrKeyDestroyed = errors.New("chronicle: subject key destroyed") + var ErrMissingActor = errors.New("chronicle: actor required") + var ErrMissingEntityID = errors.New("chronicle: entity ID required") + var ErrMissingHoldID = errors.New("chronicle: hold ID required") + var ErrNoChain = errors.New("chronicle: no hash chain") + var ErrNoKeyring = errors.New("chronicle: no keyring configured") + var ErrNotFound = errors.New("chronicle: not found") + var ErrReservedMeta = errors.New("chronicle: reserved metadata key") + var ErrShredded = errors.New("chronicle: data shredded") + var ErrUnknownIntent = errors.New("chronicle: unknown intent") + var ErrUnknownKind = errors.New("chronicle: unknown kind") + var ErrZeroTxTime = errors.New("chronicle: zero transaction instant") + func CompareRecords(a, b Record) int + type Actor struct + ID string + Name string + Type string + func (a Actor) IsZero() bool + type ApplyRequest struct + Entity EntityRef + Plan Planner + TxAt time.Time + Valid Interval + type As struct + TxAt time.Time + ValidAt time.Time + func AsOf(tx time.Time) As + func Believed(tx time.Time) As + func Now() As + func ValidAt(t time.Time) As + func (a As) IsZero() bool + type ChainError struct + EntityID string + Err error + Kind string + func (e *ChainError) Error() string + func (e *ChainError) Unwrap() error + type ChangeOp uint8 + const ChangeAdded + const ChangeModified + const ChangeRemoved + func (o ChangeOp) String() string + type Clock interface + Now func() time.Time + var SystemClock Clock = ClockFunc(func() time.Time { ... }) + type ClockFunc func() time.Time + func (f ClockFunc) Now() time.Time + type Codec interface + Decode func(data []byte) (map[string]any, error) + Name func() string + type CodecError struct + Codec string + Err error + RecordID RecordID + func (e *CodecError) Error() string + func (e *CodecError) Is(target error) bool + func (e *CodecError) Unwrap() error + type ConflictError struct + Attempts int + Err error + Reason string + func (e *ConflictError) Error() string + func (e *ConflictError) Is(target error) bool + func (e *ConflictError) Unwrap() error + type Cursor string + const NoCursor + func EncodeCursor(r Record) Cursor + func (c Cursor) IsZero() bool + func (c Cursor) String() string + type CursorError struct + Cursor Cursor + Err error + Reason string + func (e *CursorError) Error() string + func (e *CursorError) Unwrap() error + type CursorKey struct + ID RecordID + TxFrom time.Time + ValidFrom time.Time + func DecodeCursor(c Cursor) (CursorKey, error) + func (k CursorKey) After(r Record, descending bool) bool + type DeleteError struct + Err error + RecordID RecordID + func (e *DeleteError) Error() string + func (e *DeleteError) Unwrap() error + type Deleter interface + Delete func(ctx context.Context, ids []RecordID) (int, error) + Tombstones func(ctx context.Context, kind, entityID string) ([]Tombstone, error) + type Delta struct + Changes []FieldChange + EntityID string + From As + FromRecord *Record + Kind string + To As + ToRecord *Record + func (d Delta) Change(path string) (FieldChange, bool) + func (d Delta) IsEmpty() bool + func (d Delta) Paths() []string + type Divergence struct + Position int + Reason string + RecordID RecordID + type EntityRef struct + EntityID string + Kind string + type FieldChange struct + New any + Old any + Op ChangeOp + Path string + type FixedClock struct + T time.Time + func NewFixedClock(t time.Time) *FixedClock + func (c *FixedClock) Advance(d time.Duration) time.Time + func (c *FixedClock) Now() time.Time + func (c *FixedClock) Set(t time.Time) + type GetQuery struct + EntityID string + Kind string + TxAt time.Time + ValidAt time.Time + type HistoryOption func(*Query) + func ByActor(actorID string) HistoryOption + func CurrentOnly() HistoryOption + func Descending() HistoryOption + func InTxRange(iv Interval) HistoryOption + func InValidRange(iv Interval) HistoryOption + func Limit(n int) HistoryOption + func WithIntent(i Intent) HistoryOption + type Hold struct + EffectiveFrom time.Time + EntityID string + ID string + Kind string + PlacedAt time.Time + PlacedBy Actor + Reason string + ReleaseReason string + ReleasedAt time.Time + ReleasedBy Actor + func (h Hold) ActiveAt(t time.Time) bool + func (h Hold) Matches(r Record) bool + func (h Hold) Validate() error + type HoldError struct + Err error + ID string + func (e *HoldError) Error() string + func (e *HoldError) Unwrap() error + type HoldStore interface + Holds func(ctx context.Context) ([]Hold, error) + PlaceHold func(ctx context.Context, h Hold) (Hold, error) + ReleaseHold func(ctx context.Context, id string, by Actor, reason string) (Hold, error) + type Intent uint8 + const IntentAssert + const IntentCorrection + const IntentRemainder + func (i Intent) String() string + type IntentError struct + Err error + Intent Intent + func (e *IntentError) Error() string + func (e *IntentError) Unwrap() error + type Interval struct + From time.Time + To time.Time + func Always() Interval + func Between(from, to time.Time) Interval + func Since(from time.Time) Interval + func Until(to time.Time) Interval + func (iv Interval) Contains(t time.Time) bool + func (iv Interval) Duration() (time.Duration, bool) + func (iv Interval) EndsUnbounded() bool + func (iv Interval) ExtendsBeyond(o Interval) bool + func (iv Interval) IsAlways() bool + func (iv Interval) Overlaps(o Interval) bool + func (iv Interval) StartsBefore(o Interval) bool + func (iv Interval) StartsUnbounded() bool + func (iv Interval) String() string + func (iv Interval) UTC() Interval + func (iv Interval) Validate() error + type IntervalError struct + Err error + Field string + Interval Interval + func (e *IntervalError) Error() string + func (e *IntervalError) Unwrap() error + type JSONCodec struct + func (JSONCodec) Decode(data []byte) (map[string]any, error) + func (JSONCodec) Name() string + type KeyError struct + Err error + Subject string + func (e *KeyError) Error() string + func (e *KeyError) Unwrap() error + type Keyring interface + DestroyKey func(ctx context.Context, subject string) error + Key func(ctx context.Context, subject string) ([]byte, error) + type KindError struct + Err error + Kind string + func (e *KindError) Error() string + func (e *KindError) Unwrap() error + type Log struct + func NewLog(store Store, opts ...Option) *Log + func (l *Log) ChainHead(ctx context.Context, kind, entityID string) ([]byte, error) + func (l *Log) Codec() Codec + func (l *Log) Correct(ctx context.Context, kind, entityID string, data []byte, ...) (Result, error) + func (l *Log) CorrectInterval(ctx context.Context, kind, entityID string, data []byte, valid Interval, ...) (Result, error) + func (l *Log) Decrypt(ctx context.Context, r Record) (Record, error) + func (l *Log) Diff(ctx context.Context, kind, entityID string, from, to As) (Delta, error) + func (l *Log) Get(ctx context.Context, kind, entityID string, as As) (*Record, error) + func (l *Log) History(ctx context.Context, kind, entityID string, opts ...HistoryOption) ([]Record, error) + func (l *Log) Put(ctx context.Context, kind, entityID string, data []byte, ...) (Result, error) + func (l *Log) PutInterval(ctx context.Context, kind, entityID string, data []byte, valid Interval, ...) (Result, error) + func (l *Log) Query(ctx context.Context, q Query) ([]Record, Cursor, error) + func (l *Log) Timeline(ctx context.Context, kind, entityID string, as As) ([]Record, error) + func (l *Log) Verify(ctx context.Context, kind, entityID string) (VerifyReport, error) + type MemKeyring struct + func NewMemKeyring() *MemKeyring + func (k *MemKeyring) DestroyKey(ctx context.Context, subject string) error + func (k *MemKeyring) Key(ctx context.Context, subject string) ([]byte, error) + type MemStore struct + func NewMemStore() *MemStore + func (s *MemStore) Apply(ctx context.Context, req ApplyRequest) (time.Time, error) + func (s *MemStore) Close() error + func (s *MemStore) Delete(ctx context.Context, ids []RecordID) (int, error) + func (s *MemStore) Get(ctx context.Context, q GetQuery) (*Record, error) + func (s *MemStore) Holds(ctx context.Context) ([]Hold, error) + func (s *MemStore) Len() int + func (s *MemStore) PlaceHold(ctx context.Context, h Hold) (Hold, error) + func (s *MemStore) Query(ctx context.Context, q Query) ([]Record, Cursor, error) + func (s *MemStore) ReleaseHold(ctx context.Context, id string, by Actor, reason string) (Hold, error) + func (s *MemStore) Tombstones(ctx context.Context, kind, entityID string) ([]Tombstone, error) + type NotFoundError struct + As As + EntityID string + Kind string + func (e *NotFoundError) Error() string + func (e *NotFoundError) Unwrap() error + type Option func(*Log) + func WithChaining() Option + func WithClock(c Clock) Option + func WithCodec(c Codec) Option + func WithKeyring(k Keyring) Option + func WithKinds(kinds ...string) Option + func WithWriteRetries(n int) Option + type Planner func(current []Record, txAt time.Time) (Write, error) + func StaticWrite(w Write) Planner + type Query struct + ActorID string + After Cursor + CurrentOnly bool + Descending bool + EntityID string + HasIntent bool + Intent Intent + Kind string + Limit int + Tx Interval + TxAt time.Time + Valid Interval + ValidAt time.Time + func (q Query) Matches(r Record) bool + func (q Query) Validate() error + type Record struct + Actor Actor + Data []byte + EntityID string + ID RecordID + Intent Intent + Kind string + Meta map[string]string + Reason string + TxFrom time.Time + TxTo time.Time + ValidFrom time.Time + ValidTo time.Time + func (r Record) Clone() Record + func (r Record) IsCurrent() bool + func (r Record) Tx() Interval + func (r Record) Valid() Interval + type RecordID string + type Result struct + Record Record + Superseded []RecordID + TxAt time.Time + Written []Record + type ShredError struct + Err error + Reason string + RecordID RecordID + Subject string + func (e *ShredError) Error() string + func (e *ShredError) Is(target error) bool + func (e *ShredError) Unwrap() error + type Store interface + Apply func(ctx context.Context, req ApplyRequest) (time.Time, error) + Get func(ctx context.Context, q GetQuery) (*Record, error) + Query func(ctx context.Context, q Query) ([]Record, Cursor, error) + type Tombstone struct + ChainHash string + DeletedAt time.Time + EntityID string + Kind string + RecordID RecordID + TxFrom time.Time + ValidFrom time.Time + type VerifyReport struct + ChainedRecords int + Divergence *Divergence + EntityID string + Head []byte + Kind string + Tombstones int + UnchainedPrefix int + func (r VerifyReport) Intact() bool + type Write struct + Insert []Record + Supersede []RecordID + func (w Write) Entities() []EntityRef + type WriteOption func(*writeOpts) + func WithMeta(meta map[string]string) WriteOption + func WithMetaValue(key, value string) WriteOption + func WithReason(reason string) WriteOption + func WithSubject(subject string) WriteOption