Skip to main content

Module event_loop

Module event_loop 

Source
Expand description

Event loop for reducer-based pipeline architecture.

This module implements the main event loop that coordinates reducer, effect handlers, and orchestration logic. It provides a unified way to run the pipeline using the event-sourced architecture from RFC-004.

§Non-Terminating Pipeline Architecture

The pipeline is designed to be non-terminating by default for unattended operation. It must NEVER exit early due to internal failures, budget exhaustion, or agent errors.

§Failure Handling Flow

  1. Any terminal failure (Status: Failed, budget exhausted, agent chain exhausted) transitions to AwaitingDevFix phase
  2. TriggerDevFixFlow effect writes completion marker to .agent/tmp/completion_marker
  3. Dev-fix agent is optionally dispatched for remediation attempt
  4. CompletionMarkerEmitted event transitions to Interrupted phase
  5. SaveCheckpoint effect saves state for resume
  6. Event loop returns EventLoopResult { completed: true, ... }

§Acceptable Termination Reasons

The ONLY acceptable reasons for pipeline termination are catastrophic external events:

  • Process termination (SIGKILL)
  • Machine outage / power loss
  • OS kill signal
  • Unrecoverable panic in effect handler (caught and logged)

All internal errors route through the failure handling flow above.

§Module Organization

  • config - Event loop configuration and initialization
  • trace - Event trace buffer and diagnostics
  • error_handling - Panic recovery and error extraction
  • driver - Main iteration loop implementing orchestrate→handle→reduce cycle
  • recovery - Defensive completion and max iterations handling
  • core - Public API and convenience functions

Structs§

EventLoopConfig
Configuration for event loop.
EventLoopResult
Result of event loop execution.

Constants§

MAX_EVENT_LOOP_ITERATIONS
Maximum iterations for the main event loop to prevent infinite loops.

Traits§

StatefulHandler
Trait for handlers that maintain internal state.

Functions§

run_event_loop
Run the main event loop for the reducer-based pipeline.
run_event_loop_with_handler
Run the event loop with a custom effect handler.