rollup

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rollup is the single write path for events: it stores the event, upserts the session, prices assistant turns, and maintains session_stats / daily_stats / session_files in one transaction, then publishes live frames. Every producer (hookd, ingest, harness) goes through Recorder.Record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {
	Store *store.Store
	Table *cost.Table
	Bus   *bus.Bus
	Log   *slog.Logger
	// Now is overridable in tests.
	Now func() time.Time
	// Location decides which calendar day a turn belongs to (daily_stats).
	Location *time.Location
}

Recorder wires store + pricing + bus.

func New

func New(st *store.Store, tb *cost.Table, b *bus.Bus, log *slog.Logger) *Recorder

New builds a Recorder with sane defaults.

func (*Recorder) MarkIdle

func (r *Recorder) MarkIdle(ctx context.Context, idleAfter, endAfter time.Duration) error

MarkIdle flips sessions silent for longer than idleAfter to idle, and sessions silent for longer than endAfter (when > 0) to ended, publishing their new state. Called periodically by the daemon.

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, ev *event.Event, info SessionInfo) (Result, error)

Record stores one event and updates every rollup. It is safe to call from multiple goroutines; the store serializes writers.

type Result

type Result struct {
	Stored   bool // false when the event was a duplicate
	Event    event.Event
	Session  store.Session
	Stats    store.Stats
	Priced   bool // cost computed for this event
	NewFiles int  // files touched for the first time by this event
}

Result reports what Record did, for callers that need to fan out further.

type SessionFrame

type SessionFrame struct {
	Session store.Session `json:"session"`
	Stats   store.Stats   `json:"stats"`
}

SessionFrame is the payload of a "session" live frame.

type SessionInfo

type SessionInfo struct {
	Cwd, TranscriptPath, GitBranch, Version, Model string
}

SessionInfo is what a producer knows about the session an event belongs to. Empty fields are "unknown", never overwrite.

Jump to

Keyboard shortcuts

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