//! Vapora Workflow Engine
//!
//! Orchestrates multi-stage workflows with learning-based agent selection,
//! artifact passing between stages, and cost-aware LLM routing.
//!
//! # Architecture
//!
//! The workflow engine uses a state machine approach where each
//! WorkflowInstance tracks progress through stages. Each stage can execute
//! tasks in parallel or sequentially, with artifacts passed between stages via
//! the Knowledge Graph.
//!
//! # Key Components
//!
//! - `WorkflowOrchestrator`: Main coordinator managing workflow lifecycle
//! - `WorkflowInstance`: State machine tracking individual workflow execution
//! - `StageState`: Manages stage execution and task assignment
//! - `Artifact`: Data passed between stages
//! - `SurrealWorkflowStore`: Persistence layer — crash-recoverable via
//!   SurrealDB
//! - `SagaCompensator`: Rolls back completed stages on failure (reverse-order
//!   dispatch)
//! - `CedarAuthorizer`: Per-stage Cedar policy enforcement

pub mod artifact;
pub mod auth;
pub mod config;
pub mod error;
pub mod instance;
pub mod metrics;
pub mod orchestrator;
pub mod persistence;
pub mod saga;
pub mod schedule;
pub mod schedule_store;
pub mod scheduler;
pub mod stage;

pub use artifact::{Artifact, ArtifactType};
pub use auth::CedarAuthorizer;
pub use config::{EngineConfig, ScheduleConfig, StageConfig, WorkflowConfig, WorkflowsConfig};
pub use error::{ConfigError, Result, ScheduleError, WorkflowError};
pub use instance::{WorkflowInstance, WorkflowStatus};
pub use metrics::WorkflowMetrics;
pub use orchestrator::WorkflowOrchestrator;
pub use persistence::SurrealWorkflowStore;
pub use saga::SagaCompensator;
pub use schedule::{
    compute_next_fire_after, compute_next_fire_after_tz, compute_next_fire_at,
    compute_next_fire_at_tz, validate_cron_expression, validate_timezone, RunStatus, ScheduleRun,
    ScheduledWorkflow,
};
pub use schedule_store::ScheduleStore;
pub use scheduler::WorkflowScheduler;
pub use stage::{StageState, StageStatus, TaskState, TaskStatus};
