Documentation
¶
Overview ¶
Package events is the append-only event log: the single write path for the record of everything (session lifecycle, memory write/read/supersede, injection, task transition, gardener action). Telemetry, retrieval stats, and the console feed all derive from this log. SSE fan-out is added in a later phase.
Index ¶
- func Truncate(s string, maxRunes int) string
- type KindTick
- type Recorder
- func (r *Recorder) ByID(ctx context.Context, id string) (core.Event, bool, error)
- func (r *Recorder) ByKinds(ctx context.Context, kinds []core.EventKind, beforeTS, beforeID string, ...) ([]core.Event, error)
- func (r *Recorder) ByKindsSince(ctx context.Context, kinds []core.EventKind, sinceTS, sinceID string, ...) ([]core.Event, error)
- func (r *Recorder) BySession(ctx context.Context, sessionID string, limit int) ([]core.Event, error)
- func (r *Recorder) KindTimeline(ctx context.Context, kinds []core.EventKind, project, sinceTS string, ...) ([]KindTick, error)
- func (r *Recorder) PruneKinds(ctx context.Context, kinds []core.EventKind, before time.Time) (int64, error)
- func (r *Recorder) RecentExcluding(ctx context.Context, limit int, exclude ...core.EventKind) ([]core.Event, error)
- func (r *Recorder) Record(ctx context.Context, e core.Event) (string, error)
- func (r *Recorder) Subscribe() (<-chan core.Event, func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Truncate ¶
Truncate caps s to maxRunes runes, appending truncationMarker when it trims. A non-positive maxRunes disables truncation (returns s unchanged) -- the default for captured Interactions content, where retention pruning rather than truncation is the growth control. Rune-safe: never splits a multibyte rune.
Types ¶
type KindTick ¶
KindTick is one event's timestamp and kind -- the minimal projection the console buckets into the interaction-volume histogram.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder appends events to the log, reads them back, and fans successfully recorded events out to live subscribers (the console SSE feed).
func NewRecorder ¶
NewRecorder returns a Recorder backed by db.
func (*Recorder) ByID ¶
ByID returns a single event by its id. ok is false (with a nil error) when no event has that id.
func (*Recorder) ByKinds ¶
func (r *Recorder) ByKinds(ctx context.Context, kinds []core.EventKind, beforeTS, beforeID string, limit int) ([]core.Event, error)
ByKinds returns events of any of the given kinds, newest first, strictly older than the compound (beforeTS, beforeID) cursor when it is set -- so a caller can page backwards through the Interactions feed without missing or repeating rows across a ts tie (ids are ULIDs, lexically ordered like ts). An empty kinds slice returns nil; a non-positive limit defaults to 200.
func (*Recorder) ByKindsSince ¶
func (r *Recorder) ByKindsSince(ctx context.Context, kinds []core.EventKind, sinceTS, sinceID string, limit int) ([]core.Event, error)
ByKindsSince returns events of any of the given kinds strictly newer than the (sinceTS, sinceID) cursor, oldest first -- the gap-fill query an SSE client runs after a reconnect to recover rows it missed. An empty kinds slice returns nil; a non-positive limit defaults to 200.
func (*Recorder) BySession ¶
func (r *Recorder) BySession(ctx context.Context, sessionID string, limit int) ([]core.Event, error)
BySession returns a session's events in chronological order (oldest first), so a caller can render the session's timeline. A non-positive limit defaults to 500.
func (*Recorder) KindTimeline ¶
func (r *Recorder) KindTimeline(ctx context.Context, kinds []core.EventKind, project, sinceTS string, limit int) ([]KindTick, error)
KindTimeline returns the (ts, kind) of every event of the given kinds at or after sinceTS, newest first and capped at limit. project scopes to one project slug when non-empty. Only two columns are read, so a wide window stays cheap. An empty sinceTS spans all history (bounded by limit); an empty kinds slice or non-positive limit returns nil.
func (*Recorder) PruneKinds ¶
func (r *Recorder) PruneKinds(ctx context.Context, kinds []core.EventKind, before time.Time) (int64, error)
PruneKinds deletes events of the given kinds recorded strictly before cutoff, returning the number removed. It is the retention path for transport-level Interactions events (tool.call, hook.prompt); domain events are never passed in. An empty kinds slice or zero cutoff deletes nothing.
func (*Recorder) RecentExcluding ¶
func (r *Recorder) RecentExcluding(ctx context.Context, limit int, exclude ...core.EventKind) ([]core.Event, error)
RecentExcluding returns the most recent events, newest first, omitting the given kinds -- the overview's business-level feed, which hides transport-level tool.call / hook.prompt noise. A non-positive limit defaults to 50.