events

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeRawMemoryCreated       = "raw_memory_created"
	TypeMemoryEncoded          = "memory_encoded"
	TypeMemoryAccessed         = "memory_accessed"
	TypeConsolidationStarted   = "consolidation_started"
	TypeConsolidationCompleted = "consolidation_completed"
	TypeQueryExecuted          = "query_executed"
	TypeMetaCycleCompleted     = "meta_cycle_completed"
	TypeDreamCycleCompleted    = "dream_cycle_completed"
	TypeSystemHealth           = "system_health"
	TypeWatcherEvent           = "watcher_event"
	TypeEpisodeClosed          = "episode_closed"
	TypePatternDiscovered      = "pattern_discovered"
)

--- Event type constants ---

View Source
const TypeAbstractionCreated = "abstraction_created"

AbstractionCreated is emitted when a new principle or axiom is synthesized.

View Source
const TypeAssociationsPendingClassification = "associations_pending_classification"
View Source
const TypeForumMentionDetected = "forum_mention_detected"

ForumMentionDetected is emitted when an @mention is detected in a forum post.

View Source
const TypeForumPostCreated = "forum_post_created"

ForumPostCreated is emitted when a new forum post is created (human or agent).

View Source
const TypeMemoryAmended = "memory_amended"

MemoryAmended is emitted when a memory's content is updated in place.

View Source
const TypeSessionEnded = "session_ended"

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractionCreated

type AbstractionCreated struct {
	AbstractionID string    `json:"abstraction_id"`
	Level         int       `json:"level"` // 2=principle, 3=axiom
	Title         string    `json:"title"`
	SourceCount   int       `json:"source_count"`
	Ts            time.Time `json:"timestamp"`
}

func (AbstractionCreated) EventTimestamp

func (e AbstractionCreated) EventTimestamp() time.Time

func (AbstractionCreated) EventType

func (e AbstractionCreated) EventType() string

type AssocCandidate

type AssocCandidate struct {
	SourceID string `json:"source_id"`
	TargetID string `json:"target_id"`
	Summary1 string `json:"summary1"`
	Summary2 string `json:"summary2"`
}

AssocCandidate is a pending association for LLM reclassification.

type AssociationsPendingClassification

type AssociationsPendingClassification struct {
	Candidates []AssocCandidate `json:"candidates"`
	Ts         time.Time        `json:"timestamp"`
}

AssociationsPendingClassification is emitted when associations default to "similar" and may benefit from LLM-based reclassification to more specific types.

func (AssociationsPendingClassification) EventTimestamp

func (e AssociationsPendingClassification) EventTimestamp() time.Time

func (AssociationsPendingClassification) EventType

type Bus

type Bus interface {
	// Publish sends an event to all subscribers of its type.
	Publish(ctx context.Context, event Event) error

	// Subscribe registers a handler for a specific event type.
	// Returns a subscription ID for unsubscribing.
	Subscribe(eventType string, handler Handler) string

	// Unsubscribe removes a handler by its subscription ID.
	Unsubscribe(subscriptionID string)

	// Close shuts down the event bus.
	Close() error
}

Bus is the abstraction for internal event pub/sub.

type ConsolidationCompleted

type ConsolidationCompleted struct {
	DurationMs            int64     `json:"duration_ms"`
	MemoriesProcessed     int       `json:"memories_processed"`
	MemoriesDecayed       int       `json:"memories_decayed"`
	MergedClusters        int       `json:"merged_clusters"`
	AssociationsPruned    int       `json:"associations_pruned"`
	TransitionedFading    int       `json:"transitioned_fading"`
	TransitionedArchived  int       `json:"transitioned_archived"`
	PatternsExtracted     int       `json:"patterns_extracted"`
	PatternsDecayed       int       `json:"patterns_decayed"`
	NeverRecalledArchived int       `json:"never_recalled_archived"`
	Ts                    time.Time `json:"timestamp"`
}

ConsolidationCompleted is emitted when a consolidation cycle finishes.

func (ConsolidationCompleted) EventTimestamp

func (e ConsolidationCompleted) EventTimestamp() time.Time

func (ConsolidationCompleted) EventType

func (e ConsolidationCompleted) EventType() string

type ConsolidationStarted

type ConsolidationStarted struct {
	Ts time.Time `json:"timestamp"`
}

ConsolidationStarted is emitted when a consolidation cycle begins.

func (ConsolidationStarted) EventTimestamp

func (e ConsolidationStarted) EventTimestamp() time.Time

func (ConsolidationStarted) EventType

func (e ConsolidationStarted) EventType() string

type DreamCycleCompleted

type DreamCycleCompleted struct {
	MemoriesReplayed         int       `json:"memories_replayed"`
	AssociationsStrengthened int       `json:"associations_strengthened"`
	NewAssociationsCreated   int       `json:"new_associations_created"`
	CrossProjectLinks        int       `json:"cross_project_links"`
	PatternLinks             int       `json:"pattern_links"`
	InsightsGenerated        int       `json:"insights_generated"`
	NoisyMemoriesDemoted     int       `json:"noisy_memories_demoted"`
	DurationMs               int64     `json:"duration_ms"`
	Ts                       time.Time `json:"timestamp"`
}

DreamCycleCompleted is emitted when the dreaming agent completes a replay cycle.

func (DreamCycleCompleted) EventTimestamp

func (e DreamCycleCompleted) EventTimestamp() time.Time

func (DreamCycleCompleted) EventType

func (e DreamCycleCompleted) EventType() string

type EpisodeClosed

type EpisodeClosed struct {
	EpisodeID   string    `json:"episode_id"`
	Title       string    `json:"title"`
	EventCount  int       `json:"event_count"`
	DurationSec int       `json:"duration_sec"`
	Project     string    `json:"project,omitempty"`
	Ts          time.Time `json:"timestamp"`
}

EpisodeClosed is emitted when an episode is synthesized and closed.

func (EpisodeClosed) EventTimestamp

func (e EpisodeClosed) EventTimestamp() time.Time

func (EpisodeClosed) EventType

func (e EpisodeClosed) EventType() string

type Event

type Event interface {
	EventType() string
	EventTimestamp() time.Time
}

Event is the base interface for all events.

type ForumMentionDetected added in v0.34.0

type ForumMentionDetected struct {
	PostID    string    `json:"post_id"`
	ThreadID  string    `json:"thread_id"`
	AgentKey  string    `json:"agent_key"`            // "retrieval", "metacognition", etc.
	Content   string    `json:"content"`              // the post text for context
	EpisodeID string    `json:"episode_id,omitempty"` // if the mention is from an episode thread
	Ts        time.Time `json:"timestamp"`
}

func (ForumMentionDetected) EventTimestamp added in v0.34.0

func (e ForumMentionDetected) EventTimestamp() time.Time

func (ForumMentionDetected) EventType added in v0.34.0

func (e ForumMentionDetected) EventType() string

type ForumPostCreated added in v0.34.0

type ForumPostCreated struct {
	PostID     string    `json:"post_id"`
	ThreadID   string    `json:"thread_id"`
	ParentID   string    `json:"parent_id,omitempty"`
	AuthorType string    `json:"author_type"` // "human", "agent"
	AuthorName string    `json:"author_name"`
	AuthorKey  string    `json:"author_key,omitempty"`
	Content    string    `json:"content"`
	Mentions   []string  `json:"mentions,omitempty"`
	Ts         time.Time `json:"timestamp"`
}

func (ForumPostCreated) EventTimestamp added in v0.34.0

func (e ForumPostCreated) EventTimestamp() time.Time

func (ForumPostCreated) EventType added in v0.34.0

func (e ForumPostCreated) EventType() string

type Handler

type Handler func(ctx context.Context, event Event) error

Handler processes an event.

type InMemoryBus

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

InMemoryBus is an in-memory, thread-safe event bus with async dispatch.

func NewInMemoryBus

func NewInMemoryBus(bufferSize int) *InMemoryBus

NewInMemoryBus creates a new in-memory event bus with the specified buffer size. It starts a background dispatch goroutine.

func (*InMemoryBus) Close

func (b *InMemoryBus) Close() error

Close shuts down the event bus, drains pending events, and waits for the dispatch goroutine to complete.

func (*InMemoryBus) Publish

func (b *InMemoryBus) Publish(ctx context.Context, event Event) error

Publish sends an event to all subscribers of its type. If the buffer is full, logs a warning and drops the event.

func (*InMemoryBus) Subscribe

func (b *InMemoryBus) Subscribe(eventType string, handler Handler) string

Subscribe registers a handler for a specific event type. Returns a unique subscription ID.

func (*InMemoryBus) Unsubscribe

func (b *InMemoryBus) Unsubscribe(subscriptionID string)

Unsubscribe removes a handler by its subscription ID.

type MemoryAccessed

type MemoryAccessed struct {
	MemoryIDs []string  `json:"memory_ids"`
	QueryID   string    `json:"query_id"`
	Ts        time.Time `json:"timestamp"`
}

MemoryAccessed is emitted when memories are retrieved.

func (MemoryAccessed) EventTimestamp

func (e MemoryAccessed) EventTimestamp() time.Time

func (MemoryAccessed) EventType

func (e MemoryAccessed) EventType() string

type MemoryAmended added in v0.22.0

type MemoryAmended struct {
	MemoryID   string    `json:"memory_id"`
	OldSummary string    `json:"old_summary"`
	NewSummary string    `json:"new_summary"`
	Ts         time.Time `json:"timestamp"`
}

func (MemoryAmended) EventTimestamp added in v0.22.0

func (e MemoryAmended) EventTimestamp() time.Time

func (MemoryAmended) EventType added in v0.22.0

func (e MemoryAmended) EventType() string

type MemoryEncoded

type MemoryEncoded struct {
	MemoryID            string    `json:"memory_id"`
	RawID               string    `json:"raw_id"`
	Concepts            []string  `json:"concepts"`
	AssociationsCreated int       `json:"associations_created"`
	Ts                  time.Time `json:"timestamp"`
}

MemoryEncoded is emitted when a raw memory has been encoded and stored.

func (MemoryEncoded) EventTimestamp

func (e MemoryEncoded) EventTimestamp() time.Time

func (MemoryEncoded) EventType

func (e MemoryEncoded) EventType() string

type MetaCycleCompleted

type MetaCycleCompleted struct {
	ObservationsLogged int       `json:"observations_logged"`
	Ts                 time.Time `json:"timestamp"`
}

MetaCycleCompleted is emitted when meta-cognition completes a monitoring cycle.

func (MetaCycleCompleted) EventTimestamp

func (e MetaCycleCompleted) EventTimestamp() time.Time

func (MetaCycleCompleted) EventType

func (e MetaCycleCompleted) EventType() string

type PatternDiscovered

type PatternDiscovered struct {
	PatternID     string    `json:"pattern_id"`
	Title         string    `json:"title"`
	PatternType   string    `json:"pattern_type"`
	Project       string    `json:"project,omitempty"`
	EvidenceCount int       `json:"evidence_count"`
	Ts            time.Time `json:"timestamp"`
}

PatternDiscovered is emitted when a new pattern is extracted from memory clusters.

func (PatternDiscovered) EventTimestamp

func (e PatternDiscovered) EventTimestamp() time.Time

func (PatternDiscovered) EventType

func (e PatternDiscovered) EventType() string

type QueryExecuted

type QueryExecuted struct {
	QueryID         string    `json:"query_id"`
	QueryText       string    `json:"query_text"`
	ResultsReturned int       `json:"results_returned"`
	TookMs          int64     `json:"took_ms"`
	Ts              time.Time `json:"timestamp"`
}

QueryExecuted is emitted when a query is processed.

func (QueryExecuted) EventTimestamp

func (e QueryExecuted) EventTimestamp() time.Time

func (QueryExecuted) EventType

func (e QueryExecuted) EventType() string

type RawMemoryCreated

type RawMemoryCreated struct {
	ID             string    `json:"id"`
	Source         string    `json:"source"`
	HeuristicScore float32   `json:"heuristic_score"`
	Salience       float32   `json:"salience"`
	Ts             time.Time `json:"timestamp"`
}

RawMemoryCreated is emitted when a raw memory is ingested.

func (RawMemoryCreated) EventTimestamp

func (e RawMemoryCreated) EventTimestamp() time.Time

func (RawMemoryCreated) EventType

func (e RawMemoryCreated) EventType() string

type SessionEnded added in v0.19.0

type SessionEnded struct {
	SessionID string    `json:"session_id"`
	Project   string    `json:"project"`
	Ts        time.Time `json:"timestamp"`
}

SessionEnded is emitted when an MCP session disconnects (stdin EOF).

func (SessionEnded) EventTimestamp added in v0.19.0

func (e SessionEnded) EventTimestamp() time.Time

func (SessionEnded) EventType added in v0.19.0

func (e SessionEnded) EventType() string

type SystemHealth

type SystemHealth struct {
	LLMAvailable   bool      `json:"llm_available"`
	StoreHealthy   bool      `json:"store_healthy"`
	ActiveWatchers int       `json:"active_watchers"`
	MemoryCount    int       `json:"memory_count"`
	Ts             time.Time `json:"timestamp"`
}

SystemHealth is emitted periodically with system status.

func (SystemHealth) EventTimestamp

func (e SystemHealth) EventTimestamp() time.Time

func (SystemHealth) EventType

func (e SystemHealth) EventType() string

type WatcherEvent

type WatcherEvent struct {
	Source  string    `json:"source"`
	Type    string    `json:"type"`
	Path    string    `json:"path,omitempty"`
	Preview string    `json:"preview,omitempty"`
	Ts      time.Time `json:"timestamp"`
}

WatcherEvent is emitted when a watcher observes something.

func (WatcherEvent) EventTimestamp

func (e WatcherEvent) EventTimestamp() time.Time

func (WatcherEvent) EventType

func (e WatcherEvent) EventType() string

Jump to

Keyboard shortcuts

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