events

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package events defines Productize's public event envelope and in-process bus.

Index

Constants

View Source
const SchemaVersion = "1.0"

SchemaVersion identifies the current event schema emitted by Productize.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus[T any] struct {
	// contains filtered or unexported fields
}

Bus fans out typed events to bounded per-subscriber channels.

func New

func New[T any](bufSize int) *Bus[T]

New constructs a bus with a bounded channel per subscriber.

func (*Bus[T]) Close

func (b *Bus[T]) Close(ctx context.Context) error

Close unsubscribes all subscribers and closes their channels.

func (*Bus[T]) DroppedFor

func (b *Bus[T]) DroppedFor(id SubID) uint64

DroppedFor returns the number of dropped events recorded for a subscriber.

func (*Bus[T]) Publish

func (b *Bus[T]) Publish(ctx context.Context, evt T)

Publish fans out one event to the current subscriber snapshot without blocking.

func (*Bus[T]) Subscribe

func (b *Bus[T]) Subscribe() (SubID, <-chan T, func())

Subscribe registers a subscriber and returns its ID, channel, and unsubscribe function.

func (*Bus[T]) SubscriberCount

func (b *Bus[T]) SubscriberCount() int

SubscriberCount returns the number of active subscribers.

type Event

type Event struct {
	SchemaVersion string          `json:"schema_version"`
	RunID         string          `json:"run_id"`
	Seq           uint64          `json:"seq"`
	Timestamp     time.Time       `json:"ts"`
	Kind          EventKind       `json:"kind"`
	Payload       json.RawMessage `json:"payload"`
}

Event carries one versioned event envelope.

type EventKind

type EventKind string

EventKind identifies one emitted event kind.

const (
	// Run lifecycle events.
	EventKindRunQueued    EventKind = "run.queued"
	EventKindRunStarted   EventKind = "run.started"
	EventKindRunCrashed   EventKind = "run.crashed"
	EventKindRunCompleted EventKind = "run.completed"
	EventKindRunFailed    EventKind = "run.failed"
	EventKindRunCancelled EventKind = "run.cancelled"

	// Job lifecycle events.
	EventKindJobQueued          EventKind = "job.queued"
	EventKindJobStarted         EventKind = "job.started"
	EventKindJobAttemptStarted  EventKind = "job.attempt_started"
	EventKindJobAttemptFinished EventKind = "job.attempt_finished"
	EventKindJobRetryScheduled  EventKind = "job.retry_scheduled"
	EventKindJobCompleted       EventKind = "job.completed"
	EventKindJobFailed          EventKind = "job.failed"
	EventKindJobCancelled       EventKind = "job.cancelled"

	// Session events.
	EventKindSessionStarted   EventKind = "session.started"
	EventKindSessionUpdate    EventKind = "session.update"
	EventKindSessionCompleted EventKind = "session.completed"
	EventKindSessionFailed    EventKind = "session.failed"

	// Reusable-agent lifecycle events.
	EventKindReusableAgentLifecycle EventKind = "reusable_agent.lifecycle"

	// Tool call events.
	EventKindToolCallStarted EventKind = "tool_call.started"
	EventKindToolCallUpdated EventKind = "tool_call.updated"
	EventKindToolCallFailed  EventKind = "tool_call.failed"

	// Usage events.
	EventKindUsageUpdated    EventKind = "usage.updated"
	EventKindUsageAggregated EventKind = "usage.aggregated"

	// Task mutation events.
	EventKindTaskFileUpdated       EventKind = "task.file_updated"
	EventKindTaskFileSkipped       EventKind = "task.file_skipped"
	EventKindTaskMetadataRefreshed EventKind = "task.metadata_refreshed"
	EventKindTaskMemoryUpdated     EventKind = "task.memory_updated"

	// Artifact and extension events.
	EventKindArtifactUpdated EventKind = "artifact.updated"
	EventKindExtensionLoaded EventKind = "extension.loaded"
	EventKindExtensionReady  EventKind = "extension.ready"
	EventKindExtensionFailed EventKind = "extension.failed"
	EventKindExtensionEvent  EventKind = "extension.event"

	// Review mutation events.
	EventKindReviewStatusFinalized    EventKind = "review.status_finalized"
	EventKindReviewRoundRefreshed     EventKind = "review.round_refreshed"
	EventKindReviewIssueResolved      EventKind = "review.issue_resolved"
	EventKindReviewWatchStarted       EventKind = "review.watch_started"
	EventKindReviewWatchWaiting       EventKind = "review.watch_waiting"
	EventKindReviewWatchRoundFetched  EventKind = "review.watch_round_fetched"
	EventKindReviewWatchFixStarted    EventKind = "review.watch_fix_started"
	EventKindReviewWatchFixCompleted  EventKind = "review.watch_fix_completed"
	EventKindReviewWatchPushStarted   EventKind = "review.watch_push_started"
	EventKindReviewWatchPushCompleted EventKind = "review.watch_push_completed"
	EventKindReviewWatchPushFailed    EventKind = "review.watch_push_failed"
	EventKindReviewWatchClean         EventKind = "review.watch_clean"
	EventKindReviewWatchMaxRounds     EventKind = "review.watch_max_rounds"

	// Provider I/O events.
	EventKindProviderCallStarted   EventKind = "provider.call_started"
	EventKindProviderCallCompleted EventKind = "provider.call_completed"
	EventKindProviderCallFailed    EventKind = "provider.call_failed"

	// Shutdown events.
	EventKindShutdownRequested  EventKind = "shutdown.requested"
	EventKindShutdownDraining   EventKind = "shutdown.draining"
	EventKindShutdownTerminated EventKind = "shutdown.terminated"
)

type SubID

type SubID uint64

SubID identifies one bus subscription.

Directories

Path Synopsis
Package kinds defines public payloads for each Productize event kind.
Package kinds defines public payloads for each Productize event kind.

Jump to

Keyboard shortcuts

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