ralph-workflow 0.7.18

PROMPT-driven multi-agent orchestrator for git repos
Documentation
//! Unit tests for state reduction.
//!
//! Tests are organized by phase to keep files manageable and enable parallel test execution.
//! Each module tests a specific aspect of the reducer's event handling.

// Re-export common types for test modules
use crate::agents::AgentRole;
pub use crate::common::domain_types::AgentName;
pub use crate::reducer::event::{PipelineEvent, PipelinePhase};
pub use crate::reducer::state::{AgentChainState, CommitState, PipelineState, RebaseState};
pub use crate::reducer::state_reduction::reduce;

// Test modules organized by phase
mod agent_chain;
mod commit_phase;
mod continuation;
mod development_phase;
mod phase_transitions;
mod pipeline_lifecycle;
mod planning_phase;
mod rebase;
mod review_phase;

// ============================================================================
// Shared Test Helpers
// ============================================================================

/// Creates a default test state with 5 iterations and 2 reviewer passes.
/// Permissions are set to locked (simulating mid-pipeline scenario after startup).
#[must_use]
pub fn create_test_state() -> PipelineState {
    let mut state = PipelineState::initial(5, 2);
    state.agent_chain = AgentChainState::initial().with_agents(
        vec!["agent1".to_string(), "agent2".to_string()],
        vec![
            vec!["model1".to_string(), "model2".to_string()],
            vec!["fallback".to_string()],
        ],
        AgentRole::Developer,
    );
    // Tests in this module typically simulate mid-pipeline scenarios
    state.prompt_permissions.locked = true;
    state.prompt_permissions.restore_needed = true;
    state
}

/// Creates a test state in a specific phase.
#[must_use]
pub fn create_state_in_phase(phase: PipelinePhase) -> PipelineState {
    PipelineState {
        phase,
        ..create_test_state()
    }
}