ledger

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package ledger materializes read-only forensic session ledgers from events.db.

Index

Constants

View Source
const (
	DefaultUnboundPartition = "_unbound"
)

Variables

View Source
var (
	// ErrLedgerExists reports that a materialized ledger already exists with a different checksum.
	ErrLedgerExists = errors.New("sessions/ledger: ledger already exists with different content")
	// ErrInvalidRecord reports a session record that cannot produce a safe forensic path.
	ErrInvalidRecord = errors.New("sessions/ledger: invalid session ledger record")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	RootDir          string
	UnboundPartition string
	OpenEventStore   EventStoreOpener
}

Config controls forensic ledger materialization.

type EventStoreOpener

type EventStoreOpener func(ctx context.Context, sessionID string, path string) (store.EventRecorder, error)

EventStoreOpener opens the live session event database for read-only projection.

type Materializer

type Materializer struct {
	// contains filtered or unexported fields
}

Materializer projects session events into ledger.jsonl after a session ends.

func NewMaterializer

func NewMaterializer(config Config) (*Materializer, error)

NewMaterializer creates a forensic ledger materializer rooted at Config.RootDir.

func (*Materializer) DiscardSessionLedger

func (m *Materializer) DiscardSessionLedger(ctx context.Context, record store.SessionLedgerRecord) error

DiscardSessionLedger removes a deterministic materialized ledger if one exists for the session. Clear Conversation uses this before replacing the event store for the same session id.

func (*Materializer) Materialize

func (m *Materializer) Materialize(ctx context.Context, record store.SessionLedgerRecord) (result Result, err error)

Materialize writes ledger.jsonl from existing durable session evidence.

func (*Materializer) MaterializeSessionLedger

func (m *Materializer) MaterializeSessionLedger(ctx context.Context, record store.SessionLedgerRecord) error

MaterializeSessionLedger implements session.LedgerMaterializer.

func (*Materializer) Path

func (m *Materializer) Path(record store.SessionLedgerRecord) (string, error)

Path returns the deterministic ledger.jsonl path for a session.

type Result

type Result struct {
	Path     string
	Checksum string
	Events   int
	Written  bool
}

Result describes one materialization attempt.

Jump to

Keyboard shortcuts

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