Skip to main content

Module kernel

Module kernel 

Source
Expand description

Kernel - The Execution Engine

The kernel is the heart of enact-core. It:

  • Defines the execution state machine
  • Applies all state transitions through a reducer
  • Provides the ExecutionKernel for running graphs
  • Enables replay from event logs

§Architecture

┌─────────────────────────────────────────────┐
│              ExecutionKernel                │
│  ┌───────────────────────────────────────┐  │
│  │           Execution State             │  │
│  │  (ExecutionState, Steps, Artifacts)   │  │
│  └───────────────────────────────────────┘  │
│                     │                       │
│                     ▼                       │
│  ┌───────────────────────────────────────┐  │
│  │              Reducer                  │  │
│  │  (Action, State) → State              │  │
│  └───────────────────────────────────────┘  │
│                     │                       │
│                     ▼                       │
│  ┌───────────────────────────────────────┐  │
│  │           Event Emitter               │  │
│  │  (StreamEvent for UI/persistence)     │  │
│  └───────────────────────────────────────┘  │
└─────────────────────────────────────────────┘

§Key Invariants

  1. Single Source of Truth: ExecutionKernel owns the Execution state
  2. Reducer-Only Transitions: All state changes go through the reducer
  3. Deterministic: Same actions → same state (enables replay)
  4. Observable: All transitions emit events

@see docs/TECHNICAL/01-EXECUTION-TELEMETRY.md

Re-exports§

pub use ids::prefixes;
pub use ids::ArtifactId;
pub use ids::CallableType;
pub use ids::CancellationPolicy;
pub use ids::ExecutionId;
pub use ids::GraphId;
pub use ids::MessageId;
pub use ids::NodeId;
pub use ids::ParentType;
pub use ids::RunId;
pub use ids::SpawnMode;
pub use ids::StepId;
pub use ids::StepSource;
pub use ids::StepSourceType;
pub use ids::StepType;
pub use ids::TenantId;
pub use ids::ThreadId;
pub use ids::UserId;
pub use persistence::CollectionInfo;
pub use persistence::CostInfo;
pub use persistence::DistanceMetric;
pub use persistence::EventStore;
pub use persistence::ExecutionEventData;
pub use persistence::ExecutionSnapshot;
pub use persistence::ExecutionStats;
pub use persistence::FinishReason;
pub use persistence::InMemoryMessageStore;
pub use persistence::Message;
pub use persistence::MessageMetadata;
pub use persistence::MessagePart;
pub use persistence::MessageRole;
pub use persistence::MessageStore;
pub use persistence::StateStore;
pub use persistence::StateStoreJsonExt;
pub use persistence::StorageBackend;
pub use persistence::StoredEvent;
pub use persistence::Thread;
pub use persistence::TokenUsage;
pub use persistence::VectorDocument;
pub use persistence::VectorFilter;
pub use persistence::VectorSearchResult;
pub use persistence::VectorStore;
pub use cost::CostCalculator;
pub use cost::ModelPricing;
pub use cost::TokenUsage as LlmTokenUsage;
pub use cost::UsageAccumulator;

Modules§

artifact
Artifact Lifecycle - First-class kernel entities
cost
Token Usage and Cost Calculation
ids
Execution & Telemetry IDs - Graph-centric observability identifiers
persistence
Persistence Layer - Storage Abstractions

Structs§

ControlEvent
ControlEvent - Governance event for control signals
DecisionAlternative
DecisionAlternative - An alternative option that was not chosen
DecisionInput
DecisionInput - Inputs that informed the decision
DecisionRecord
DecisionRecord - Audit trail for decisions made during execution
EnforcementMiddleware
Enforcement middleware for checking limits before operations
EnforcementPolicy
Configuration for enforcement behavior
EnforcementViolation
Details of an enforcement violation
EnforcementWarning
Warning about approaching limits
Event
Event - execution event with run/node context
EventLog
Event log for replay
Execution
Execution - one run of a blueprint
ExecutionContext
ExecutionContext - Minimal context attached to every event
ExecutionError
The primary error type for all execution failures
ExecutionEvent
ExecutionEvent - Base event schema for all execution events
ExecutionKernel
ExecutionKernel - the core execution engine
ExecutionUsage
Tracks resource usage for a single execution
InterruptableRunner
Interruptable execution handler
LongRunningExecutionPolicy
Policy configuration for long-running agentic executions
ModelContext
ModelContext - Model configuration used for decision
ParallelResult
Result of a parallel execution branch
RetryPolicy
Deterministic retry behavior for an error
Step
Step - a distinct action within an execution
StepTimeoutGuard
Guard for enforcing step timeouts
UsageSnapshot
Serializable snapshot of execution usage

Enums§

BackoffStrategy
How to space out retry attempts
ControlAction
ControlAction - What control action was requested
ControlActor
ControlActor - Who/what initiated the control action
ControlOutcome
ControlOutcome - What happened as a result of the control action
DecisionType
DecisionType - Types of decisions made during execution
EnforcementResult
Result of an enforcement check
ExecutionAction
Execution event - all possible events that can change execution state
ExecutionErrorCategory
High-level error categories for deterministic recovery
ExecutionEventType
ExecutionEventType - All event types in the execution lifecycle
ExecutionState
Execution lifecycle state - explicit state machine
InterruptDecision
User decision for an interrupt
InterruptReason
Interrupt reason
LlmErrorCode
Specific LLM provider error codes
ReducerError
Reducer error
ReplayError
Replay error
StepState
Step lifecycle state
ToolErrorCode
Specific tool error codes
ViolationType
Type of enforcement violation
WaitReason
Reason for waiting state

Functions§

reduce
Apply an action to an execution, producing a new state
replay
Replay an execution from an action log
run_parallel
Run multiple callables in parallel