Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Event System

Ennio emits structured events for every significant state change. Events flow through multiple channels for real-time and historical access.

Event Structure

Every event contains:

FieldTypeDescription
idEventIdUnique identifier
event_typeEventTypeWhat happened
priorityEventPrioritySeverity level
session_idSessionIdAffected session
project_idProjectIdOwning project
timestampDateTime<Utc>When it happened
messageStringHuman-readable description
dataJSONStructured payload

Event Types

Session Events

TypeDescription
SessionSpawnedNew session created and agent launched
SessionWorkingAgent began active work
SessionExitedAgent process exited unexpectedly
SessionKilledSession manually terminated
SessionRestoredExited session restarted
SessionCleanedSession workspace cleaned up

Status Events

TypeDescription
StatusChangedSession transitioned to a new status
ActivityChangedSession activity state changed

Pull Request Events

TypeDescription
PrCreatedPull request created
PrUpdatedPull request updated (new commits)
PrMergedPull request merged
PrClosedPull request closed without merging

CI Events

TypeDescription
CiPassingCI checks are green
CiFailingCI checks failed
CiFixSentAgent pushed a CI fix
CiFixFailedCI fix attempt also failed

Review Events

TypeDescription
ReviewPendingAwaiting code review
ReviewApprovedPR approved
ReviewChangesRequestedReviewer requested changes
ReviewCommentsSentReview comments forwarded to agent

Merge Events

TypeDescription
MergeReadyPR ready to merge (approved + CI green)
MergeConflictsMerge conflicts detected
MergeCompletedPR merged successfully

Reaction Events

TypeDescription
ReactionTriggeredA reaction rule fired
ReactionEscalatedReaction escalated after timeout
AllCompleteAll project sessions completed

Node Events

TypeDescription
NodeConnectedConnected to remote node
NodeDisconnectedDisconnected from remote node
NodeLaunchedRemote node daemon started
NodeHealthCheckNode health check performed

Event Priority

PriorityUse Case
InfoStatus updates, completions
ActionSomething needs attention
UrgentImmediate human attention needed
CriticalSystem-level failures

Priorities are ordered: Info < Action < Urgent < Critical.

Event Channels

EventBus (In-Process)

Tokio broadcast channel with capacity 1024. Subscribers receive events in real-time. Used by the lifecycle manager, web API (SSE), and internal consumers.

#![allow(unused)]
fn main() {
let rx = event_bus.subscribe(EventType::CiFailing);
while let Ok(event) = rx.recv().await {
    // handle event
}
}

NATS (Distributed)

Events are published to category-based NATS topics. Each event type maps to a topic category:

CategoryTopic FormatEvent Types
Sessionsennio.sessions.{project_id}.{action}Spawned, Working, Exited, Killed, Restored, Cleaned, StatusChanged, ActivityChanged
Pull Requestsennio.pr.{project_id}.{action}PrCreated, PrUpdated, PrMerged, PrClosed
CIennio.ci.{project_id}.{action}CiPassing, CiFailing, CiFixSent, CiFixFailed
Reviewsennio.review.{project_id}.{action}ReviewPending, ReviewApproved, ReviewChangesRequested, ReviewCommentsSent
Mergeennio.merge.{project_id}.{action}MergeReady, MergeConflicts, MergeCompleted
Reactionsennio.reactions.{project_id}.{action}ReactionTriggered, ReactionEscalated
Lifecycleennio.lifecycle.{action}AllComplete
Nodesennio.node.{host}.{action}NodeConnected, NodeDisconnected, NodeLaunched, NodeHealthCheck
Commandsennio.commands.{command}Shutdown and other control commands
Metricsennio.metrics.{action}Metric collection events
Dashboardennio.dashboard.{action}Dashboard update events

External systems can subscribe to patterns:

  • ennio.sessions.my-project.* — all session events for a project
  • ennio.ci.my-project.* — all CI events for a project
  • ennio.node.build-server.* — all events from a remote node
  • ennio.lifecycle.* — all lifecycle events

Topic segments are validated: alphanumeric, underscore, and hyphen characters only. No spaces or dots within segments.

SQLite (Persistent)

All events are persisted to the events table for history, debugging, and replay. Query via the REST API or directly from the database.