Versions in this module Expand all Collapse all v0 v0.1.1 Oct 4, 2026 Changes in this version type Ledger + func (l *Ledger) ReconcileClaudeBatch(ctx context.Context, b ObservationBatch) (Applied, error) v0.1.0 Oct 3, 2026 Changes in this version + const BackupPhaseCopying + const BackupPhasePublishing + const BackupPhaseVerifying + const SchemaVersion + var ErrSchemaNewer = errors.New("store: database schema is newer than this binary") + func RecordedSchemaVersion(ctx context.Context, path string) (int, error) + type ActivityBucket struct + AttributedCostMicroUSD int64 + AttributedInput int64 + AttributedOutput int64 + AttributedTotal int64 + Calls int64 + ComputedCostCalls int64 + Keys map[string]string + OrderedKeys []string + Sessions int64 + UnattributedCalls int64 + UnpricedCalls int64 + type ActivityFilter struct + GroupBy []string + Kinds []string + Models []string + Names []string + Projects []string + Providers []string + Sessions []string + Since time.Time + Skills []string + Tools []string + Until time.Time + Values []string + type ActivityOrder string + const ActivityByCalls + const ActivityByCost + const ActivityByTokens + type ActivitySummary struct + Buckets []ActivityBucket + GroupBy []string + Totals ActivityBucket + type Applied struct + Activity int + CodeChanges int + Events int + TurnContexts int + type BackupProgress struct + Batches int64 + Phase string + type BackupResult struct + Compatible bool + Path string + RowCounts map[string]int64 + SHA256 string + SchemaVersion int + SizeBytes int64 + State VerificationState + Verification Verification + func Backup(ctx context.Context, source, destination string) (BackupResult, error) + func BackupWithProgress(ctx context.Context, source, destination string, report func(BackupProgress)) (BackupResult, error) + type Bucket struct + CacheCreation int64 + CacheRead int64 + ComputedCostEvents int64 + CostMicroUSD int64 + Events int64 + Input int64 + Keys map[string]string + OrderedKeys []string + Output int64 + Reasoning int64 + Sessions int64 + Total int64 + UnpricedEvents int64 + type CodeChangeSummary struct + KnownChanges int64 + LinesAdded int64 + LinesRemoved int64 + UnknownChanges int64 + type DBStats struct + DistinctModel int64 + DistinctTools int64 + EarliestEvent time.Time + Events int64 + LatestEvent time.Time + Path string + SchemaVersion int + SizeBytes int64 + Snapshots int64 + type Filter struct + GroupBy []string + Models []string + Projects []string + Providers []string + Sessions []string + Since time.Time + Tools []string + Until time.Time + type Ledger struct + func Open(path string) (*Ledger, error) + func (l *Ledger) ApplyBatch(ctx context.Context, b ObservationBatch) (Applied, error) + func (l *Ledger) ApplyEvents(ctx context.Context, events []model.UsageEvent, cp *model.SourceCheckpoint) (int, error) + func (l *Ledger) ApplyObservation(ctx context.Context, events []model.UsageEvent, activity []model.ActivityEvent, ...) (Applied, error) + func (l *Ledger) ApplySnapshot(ctx context.Context, events []model.UsageEvent, state model.AggregateSnapshot, ...) (int, error) + func (l *Ledger) EnsureRollup(ctx context.Context) (bool, error) + func (l *Ledger) InsertEvents(ctx context.Context, events []model.UsageEvent) (int, error) + func (l *Ledger) RebuildRollup(ctx context.Context) error + func (l *Ledger) SyncUnpriced(ctx context.Context, revision string, ...) (int, error) + func (l *Ledger) UpsertState(ctx context.Context, st model.AggregateSnapshot) error + type ListOption func(*listOptions) + func WithEventTimeKeyset(after time.Time, afterID int64, limit int) ListOption + func WithKeyset(afterID int64, limit int) ListOption + func WithRaw() ListOption + type ObservationBatch struct + Activity []model.ActivityEvent + Checkpoint *model.SourceCheckpoint + CodeChanges []model.CodeChange + Events []model.UsageEvent + TurnContexts []model.TurnContext + type PreparedRestore struct + SnapshotTime time.Time + SourcePath string + StagePath string + Verification Verification + func PrepareRestore(ctx context.Context, backupPath, targetPath string) (*PreparedRestore, error) + func (p *PreparedRestore) Cleanup() + type QuarantineResult struct + HistoricalCompletenessUnknown bool + QuarantinePath string + TargetPath string + TargetUsable bool + Verification Verification + func Quarantine(ctx context.Context, targetPath string) (QuarantineResult, error) + type Reader struct + func OpenReadOnly(path string) (*Reader, error) + func (s *Reader) Checkpoint(ctx context.Context, tool, sourcePath string) (*model.SourceCheckpoint, error) + func (s *Reader) Close() error + func (s *Reader) IngestWatermark(ctx context.Context) (time.Time, error) + func (s *Reader) LastEventTimes(ctx context.Context) (map[string]time.Time, error) + func (s *Reader) LastState(ctx context.Context, tool, key string) (*model.AggregateSnapshot, error) + func (s *Reader) ListActivity(ctx context.Context, f ActivityFilter) ([]model.ActivityEvent, error) + func (s *Reader) ListEvents(ctx context.Context, f Filter, opts ...ListOption) ([]model.UsageEvent, error) + func (s *Reader) RollupStale(ctx context.Context) (bool, error) + func (s *Reader) SessionCodeChanges(ctx context.Context, tool, sessionID, project string) (CodeChangeSummary, error) + func (s *Reader) SourceStats(ctx context.Context) ([]SourceStat, error) + func (s *Reader) Stats(ctx context.Context) (DBStats, error) + func (s *Reader) Summarize(ctx context.Context, f Filter) (*Summary, error) + func (s *Reader) SummarizeActivity(ctx context.Context, f ActivityFilter) (*ActivitySummary, error) + func (s *Reader) SummarizeRollup(ctx context.Context, f Filter) (*RollupSummary, error) + func (s *Reader) SummarizeSkillCost(ctx context.Context, f ActivityFilter) (*SkillCostSummary, error) + func (s *Reader) SummarizeTurnContext(ctx context.Context, dim model.TurnDimension, f ActivityFilter) (*TurnContextSummary, error) + func (s *Reader) TopActivity(ctx context.Context, f ActivityFilter, by ActivityOrder, limit int) ([]ActivityBucket, error) + func (s *Reader) TopSkillCost(ctx context.Context, f ActivityFilter, by ActivityOrder, limit int) ([]SkillCostBucket, error) + func (s *Reader) TopTurnContext(ctx context.Context, dim model.TurnDimension, f ActivityFilter, ...) ([]TurnContextBucket, error) + func (s *Reader) UnpricedGroups(ctx context.Context, f Filter) ([]UnpricedGroup, error) + type RestoreResult struct + CorruptQuarantinePath string + EventsMayBeAbsent bool + RolledBack bool + SafetyBackupPath string + SnapshotTime time.Time + SourcePath string + TargetPath string + TargetUsable bool + Verification Verification + func ApplyRestore(ctx context.Context, plan *PreparedRestore, targetPath string, replace bool) (RestoreResult, error) + type RollupSummary struct + Buckets []Bucket + GroupBy []string + Since time.Time + Totals Bucket + Until time.Time + type SkillCostBucket = TurnContextBucket + type SkillCostSummary = TurnContextSummary + type SkippedRow struct + DedupKey string + Err error + type SkippedRowsError struct + Rows []SkippedRow + Table string + Total int + func (e *SkippedRowsError) Error() string + func (e *SkippedRowsError) Skipped() int + func (e *SkippedRowsError) Unwrap() error + type SourceStat struct + Events int64 + FirstEvent time.Time + LastEvent time.Time + LastObserved time.Time + Models []string + Sessions int64 + Tool string + Total int64 + type Summary struct + Buckets []Bucket + GroupBy []string + Totals Bucket + type TurnContextBucket struct + ComputedCostTurns int64 + CostMicroUSD int64 + InputTokens int64 + Keys map[string]string + OrderedKeys []string + OutputTokens int64 + Sessions int64 + TotalTokens int64 + Turns int64 + UnjoinedTurns int64 + UnpricedTurns int64 + type TurnContextSummary struct + Buckets []TurnContextBucket + Dimension model.TurnDimension + GroupBy []string + Totals TurnContextBucket + type UnpricedGroup struct + CacheCreation int64 + CacheRead int64 + Events int64 + Input int64 + Keys map[string]string + Model string + OrderedKeys []string + Output int64 + Provider string + Reasoning int64 + ServiceTier string + Tool string + type Verification struct + ApplicationSchemaOK bool + Compatible bool + ForeignKeyErrors []string + ForeignKeysOK bool + IntegrityErrors []string + IntegrityOK bool + Path string + Reason string + RollupChecked bool + RollupStale bool + RowCounts map[string]int64 + SchemaErrors []string + SchemaVersion int + State VerificationState + func Verify(ctx context.Context, path string) (Verification, error) + func (v Verification) StateError() error + type VerificationState string + const VerificationCorrupt + const VerificationIncompatible + const VerificationOK + const VerificationRepairable